GROUP BY help

Hey all,
I am having a difficult time with this one, any help would be appreciated.
I have a table with 4 fields:
ID,MAIN,TIME,SPD
it would look something like this
ROWID,ID, MAIN, TIME, SPD
1, AA, 01, 1, 45
2, AA, 02, 1, 44
3, AA, 02, 2, 33
4, AA, 03, 3, 44
5, AA, 02, 5, 55
etc
What I need to do is get an AVERAGE of the SPD column
where I GROUP by ID, MAIN and (here is the hard part) TIME (ONLY if its sequential)
So by ROWID
1 would stay the same,
2 and 3 would be averaged because ID, MAIN are the same and TIME is sequential
4 and 5 would stay the same...
looked at the AVG analytical function to see if I could just create a moving average (partitioned by ID, MAIN) but it still ends up averaging rows 2,3 and 5. I imagine you could do it with PL/SQL but not very versed in cursors and the table I would be running this on numbers in the billions of rows...
Thanks ahead of time,
Eric

If i understand clearly.
with t as (
select 1 r1, 'AA' id , 01 m1, 1 t1 , 45 spd from dual union all
select 2, 'AA', 02, 1, 44 from dual union all
select 3, 'AA', 02, 2, 33 from dual union all
select 4, 'AA', 03, 3, 44 from dual union all
select 5, 'AA', 02, 5, 55 from dual )
select id,m1,avg(spd)
from (select m1,r1,id,t1,grp,spd
from t
model
partition by (m1)
dimension by (row_number() over (partition by m1 order by r1) rn )
measures (r1,id,t1,spd,lag(t1) over ( partition by m1 order by t1) next_t1,1 grp, 1 grprec)
rules
upsert
iterate(1000)
until(presentv(t1[iteration_number+2],1,0)=0)
(grprec[any] = nvl(grp[cv()-1],1),
grp[any]= case when nvl( next_t1[cv()]+1,t1[cv()]) =t1[cv()]  then               
             grprec[cv()] else  grprec[cv()]+1  end))
group by id,m1,grpoutput
AA     3     44
AA     2     55
AA     1     45
AA     2     38.5
Edited by: alvinder on Mar 4, 2009 9:51 AM
Fixed the mistake i did.

Similar Messages

  • When I try an update I-tunes the software tells me the older version of Apple Software Update cannot be removed. Contact your technical support group. Help!!!

    When I try an update I-tunes the software tells me the older version of Apple Software Update cannot be removed. Contact your technical support group. Help!!!

    Download the Windows Installer CleanUp utility from the following page (use one of the links under the thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any Apple Software Update entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • Group Policy Helper tool not working properly

    Hello,
    I`m using IE 9 on a x64 Win 7 enterprise PC with ZCM 10.3.4.
    When Im logging into ZCC and start to configure a "windows group policy" the group policy helper tool starts and begins to download the policy.
    Then the gpedit.msc appears i get the popup "group policy settings imported successfully" immediately. This popup should certainly come up, when i close the gpedit.msc to import the changed policy setting.
    But so i always get an empty policy for upload.
    Any hints what`s wrong with it?!

    Originally Posted by andreas_karl
    Hello,
    I`m using IE 9 on a x64 Win 7 enterprise PC with ZCM 10.3.4.
    When Im logging into ZCC and start to configure a "windows group policy" the group policy helper tool starts and begins to download the policy.
    Then the gpedit.msc appears i get the popup "group policy settings imported successfully" immediately. This popup should certainly come up, when i close the gpedit.msc to import the changed policy setting.
    But so i always get an empty policy for upload.
    Any hints what`s wrong with it?!
    IE 9 is not supported, you need to stay on IE8 until 11.2 is released (15 march).
    Thomas

  • Group policy helper and Folder Redirection

    I've installed windows7/32 bit to use the Group policy helper. Now I can use this tool.
    I want to use the Group policy helper to redirect folders as descripted in Managing Roaming User Data Deployment Guide.
    In this documentation a folder redirection management snap.in is used. Can I somehow include this in the grouppolicy helper in ZCC11?
    I want to redirect the user folders to their homedirectory. We have about 500 Students and I can't configure every login so I hope to solve the problem using the group policies.
    (with zen7 and XP we configure the default local user to move desktop and user files to NetWare Home directory.)

    This still works..........
    http://www.novell.com/coolsolutions/tools/14324.html
    On 7/27/2011 7:56 AM, Alix wrote:
    >
    > I've installed windows7/32 bit to use the Group policy helper. Now I can
    > use this tool.
    >
    > I want to use the Group policy helper to redirect folders as descripted
    > in 'Managing Roaming User Data Deployment Guide'
    > (http://technet.microsoft.com/de-de/l...9(WS.10).aspx).
    >
    > In this documentation a folder redirection management snap.in is used.
    > Can I somehow include this in the grouppolicy helper in ZCC11?
    >
    > I want to redirect the user folders to their homedirectory. We have
    > about 500 Students and I can't configure every login so I hope to solve
    > the problem using the group policies.
    >
    > (with zen7 and XP we configure the default local user to move desktop
    > and user files to NetWare Home directory.)
    >
    >
    Craig Wilson - MCNE, MCSE, CCNA
    Novell Knowledge Partner
    Novell does not officially monitor these forums.
    Suggestions/Opinions/Statements made by me are solely my own.
    These thoughts may not be shared by either Novell or any rational human.

  • Vendor Account Group Search Help

    Hello MM Experts,
    We would like to search Vendors by Account Group. Surprisingly it appears that SAP has not provided a standard Search Help for this. I would think that a lot of SAP users would want this.
    Does anyone know why SAP has not provided this search help in the standard system?
    Would it be ok to go ahead and create one ourselves?
    Can someone please give me some pointers on how to proceed with creation of this search help?
    Thanks!
    Anisha.

    Hi,
    Go to any vendor field, press for selection (F4)......you get many search options there.
    One of those search option is vendor by account group.
    You can also do it thru LFA1 table.
    Sk.

  • Group report help

    i want to create report in Oracle D2k (Reports 6i). Please help.
    i have 3 tables.
    1 master table: school with school_id primary key
    2 detail tables: dept & employee with school_id foreign key in both
    Now I want report like this:
    1 Delhi Public School
    school_id dept id dept name
    1 10 chemistry
    1 20 Physics
    school_id Employee_id Employee_name
    1 100 ABC
    1 200 XYZ
    2 Punjab Public Shool
    school_id dept id dept name
    2 10A Computers
    2 20B History
    school_id Employee_id Employee_name
    2 A100 12ABC
    2 C200 12XYZ
    Please help. thanks in advance.

    want to create report in Oracle D2k (Reports 6i). Please help.
    i have 3 tables.
    1 master table: school with school_id primary key
    2 detail tables: dept & employee with school_id foreign key in both
    Now I want report like this:
    1 Delhi Public School
    school_id dept id dept name
    1 10 chemistry
    1 20 Physics
    school_id Employee_id Employee_name
    1 100 ABC
    1 200 XYZ
    2 Punjab Public Shool
    school_id dept id dept name
    2 10A Computers
    2 20B History
    school_id Employee_id Employee_name
    2 A100 12ABC
    2 C200 12XYZ
    Please help. thanks in advance.
    Try below
    Select report type as group above
    sql query is like this :
    select a.schoolid, a.schoolname, b.details
    where
    a.schoo.d = b.school id
    for group above use scholl id
    You will get what you mentioned

  • Group Formula Help

    Post Author: dmface15
    CA Forum: Crystal Reports
    I have a report that identifies employees and what taxes that employee pays. For example,
    John Doe
    OASDI           $2500
    Medicare        $625
    Jane Doe
    Medicare       $1750
    Michael Smith
    OASDI          $1630
    Medicare       $783
    The report is grouped by Employee name and tax code. The reason for grouping by tax code is because the tabale i am using to get tax code has records for each pay check the employee has received. Here is the problem. I need to create a report that will give me all employees who pay Medicare AND OASDI, all employees who pay ONLY Medicare. Therefore, when I run the report for employees who pay Medicare AND OASDI I should only see Michael Smith and John Doe. If i run the report for all employees who pay ONLY Medicare I should see only Jane Doe. Right now, I am having trouble with creating a formula whether it by group selection or record selection. Can anyone help me out? I would appreciate it. Thanks.

    Post Author: kcheeb
    CA Forum: Crystal Reports
    Have you tried suppressing the group and detail sections based on the report type and count of tax code records? Assuming There are no people with only OASDI tax codes.
    The other option would be to use sql to return you only Medicare people or OASDI & Medicare people.

  • Group Messaging Help!!

    Ok so I recently got an iPhone 4s and I'm having trouble with the group messaging system. On my old phone (HTC 7 Pro, windows phone) I would keep getting individual messages from people in a group text that I have been added in. The only difference in the message was it always said, NEW MULTIMEDIA MESSAGE whenever someone in the group sent something. I would think that once I got an iPhone these issues would disappear, unfortunatly the didn't.
    On my new iPhone, it got the old group message I was in correct (the one I was added on with my old phone), but once again, whenever someone creates a new group text and adds me to it, I get the seperate messages which say MULTIMEDIA MESSAGE. I can create group messages and have them work as intended but when someone else creates it and adds me to it, I can't do anything.
    This is quite annoying because I can't send anything in the group text at all since it never registers me in the group text. I can only read the messages sent but in the messages folder, it always puts the group message from someone into the single contact message but states NEW MULTIMEDIA MESSAGE.
    Any help would be much appreciated!! FYI I have MMS messaging and group messaging enabled. I have imessage enabled and SMS messaging enabled. I turned off read receipts. Only thing that might hinder my chance at it registering the group message would be that I didn't have group messaging enabled when I was added to the group message but I've later turned it on. Plus one of my family members says that they didn't have group messaging enabled but they still receive them correctly.

    I should mention that the person who created this group chat has an android phone but everyone else in the group chat has an iPhone. Everyone in the group chat says this group messaging works fine but I seem to be the only one with the problem. All I want is for this to work like a normal group chat so I can see all the responses in one group and be able to reply so that all can see.
    If I reply to the individual contact where I got the group message, it automatically converts that to whatever form of messaging needed and only sends that person the text.

  • Cannot download newer version of itunes - older version of bonjour cannot be removed and to contact tech. support group pls. help

    Why am I not able to download the newer verion of iTunes? ......when downloading it is interrupted by"""older version of Bonjour cannot be removed-contact Tech. Supprt Group""  What am I suppost to do??  Can anyone help me with this issue.

    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any Bonjour entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • Select Union All - group by help

    I have this Query with me
    select Item_number , Total_Supplier_Qty, Total_Customer_Qty,Ship_from_org_name,inventory_item_id ,Total_onhand, min, max
    from
    select NULL AS Total_Supplier_Qty,sum(eoo.ordered_quantity) Total_Customer_Qty,
    eoo.item_number Item_number,eoo.ship_from_org_name  Ship_from_org_name,eoo.inventory_item_id
    ,Total_onhand, min,max
    from   eoo
    group by eoo.item_number,eoo.ship_from_org_name ,eoo.inventory_item_id
    UNION ALL
    select eos.QUANTITY Total_Supplier_Qty,NULL AS Total_Customer_Qty,
    eos.item_number Item_number,eos.Ship_from_org_name  Ship_from_org_name,eos.inventory_item_id
    ,Total_onhand, min, max
    from  eos group by eos.item_number,eos.ship_from_org_name ,eos.QUANTITY ,eos.inventory_item_id
    GROUP BY   
      Total_Supplier_Qty, Total_Customer_Qty,Item_number,  Ship_from_org_name,inventory_item_id
    ,Total_onhand, min, max
    order by Item_numbergiving me result
    1901,     -     *,5*     ,71317,     12,     4     ,6
    1901     ,*6,*     -     ,71317,     12,     4,     6
    I want result combined
    1901,     6,     5,     71317,     12,     4,     6
    Help please.

    select  Item_number,
            SUM(Total_Supplier_Qty) Total_Supplier_Qty,
            SUM(Total_Customer_Qty) Total_Customer_Qty,
            Ship_from_org_name,
            inventory_item_id,
            Total_onhand,
            min,
            max
      from  (
              select  NULL AS Total_Supplier_Qty,
                      sum(eoo.ordered_quantity) Total_Customer_Qty,
                      eoo.item_number Item_number,
                      eoo.ship_from_org_name Ship_from_org_name,
                      eoo.inventory_item_id,
                      Total_onhand,
                      min,
                      max
               from  eoo
               group by eoo.item_number,
                        eoo.ship_from_org_name,
                        eoo.inventory_item_id
             UNION ALL
              select  eos.QUANTITY Total_Supplier_Qty,
                      NULL AS Total_Customer_Qty,
                      eos.item_number Item_number,
                      eos.Ship_from_org_name Ship_from_org_name,
                      eos.inventory_item_id,
                      Total_onhand,
                      min,
                      max
                from  eos
                group by eos.item_number,
                         eos.ship_from_org_name,
                         eos.QUANTITY,
                         eos.inventory_item_id
      GROUP BY Item_number,
               Ship_from_org_name,
               inventory_item_id,
               Total_onhand,
               min,
               max
      order by Item_numberSY.

  • Deploying Files with Group Policy - Help Needed

    Hi,
    I am trying to use group policy to deploy files and folders to our server estate. The policy I have created first creates a folder on each server's C drive and then coppies a set of files to this folder from a network share. The folder creation works fine
    but the files copy fails. In the Application logs on the servers it displays the following error:
    The computer 'ILMT' preference item in the 'GPO - Servers_Production_ALL {CC026B58-FA3B-4399-AA00-AE8E844B2B47}' Group Policy object did not apply because it failed with error code '0x80070005 Access is denied.' This error was suppressed.
    Can anyone advise what exactly does not have access here? I don't know what I need to enable to get this to work.
    Can anyone help?
    Many thanks
    James

    The copy is on a file server share. presumably if I just give everybody read access to the share that would suffice?
    No it won't.
    "Sharing" requires several actions:
    a) create the folder
    b) share the folder
    c) grant NTFS permissions on the folder
    I think you've neglected action (c).
    For your scenario, you need to grant the "server computers" read permissions to the folder.
    You can add individual computer accounts, or a group, or "domain computers".
    (In a similar way, you could grant access to a user, a group, or "domain users")
    [if you need everybody (users) *AND* everything (computers), you could grant permissions to "authenticated users" since that principal includes *BOTH* users and also computers]
    Note that "domain computers" and "authenticated users" include all types of domain member computers, i.e. servers, workstations, etc.
    Also, note that granting a "computer account" access to a folder or share, does *NOT* mean that a user account on that computer can access the remote share, i.e. permission is granted to the computer account, and a logged-in user account on
    that computer does not inherit any kind of access to the remote share by virtue of being logged in.
    This means that the computer can access the share but the user cannot access the share. Because the computer account is an identity/principal of it's own accord.
    [None of which really has anything to do with Group Policy at all - it's how Windows does file sharing and ACLs... ;)
    Don
    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable.
    This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!)

  • Active Directory Group Cleanup - Help Needed

    Hi All,
    I need to clean up our Active Directory and the first stage of this is to remove any unused groups. I have been trying to work out what these are using powershell. Can anyone please provide me with a simple powershell script that will identify any AD groups
    that have no members in them? 
    Many thanks
    James

    Greetings!
    Try this:
    import-module activedirectory
    Get-ADGroup –Filter * -Properties Members | where { $_.Members.Count –eq 0 }
    Regards.
    Mahdi Tehrani   |  
      |  
    www.mahditehrani.ir
    Please click on Propose As Answer or
    to mark this post as
    and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.
    How to query members of 'Local Administrators' group in all computers?
    Adding in: Watch out for users having customized groups (e.g groups other than Domain Users and Domain Admins) as their primary group, they will not be reflected in the member attribute and hence not be reflected in the above count, I know it's a rare case,
    but could be good to know.
    Enfo Zipper
    Christoffer Andersson – Principal Advisor
    http://blogs.chrisse.se - Directory Services Blog

  • Function Group - CUOV; Help needed

    Hi All,
    I am designing a Function module which will be used by a Variant function (LO-Variant configuration). The function Group CUOV has the list of standard function modules. But I am not bale to create successful test data for any of them. I had asked SAP to help me with the function Module documentation, but they said no since the function modules are not RELEASED.
    Now, If, any of you have worked with these function modules, please share your code/ideas.
    ~ Guru

    I think you'll have better luck with this question in the Discoverer forum.
    Discoverer

  • OIM-OID! provisioning users to OID groups-QUICK HELP NEEDED

    hi,
    I've installed OIM connected to OID.
    I've been assign some tasks:
    1) Creating access policy such that when a user is created in OIM, he is provisioned to two groups in OID.... ie. in cn=users and cn=employees (where cn=employess is the group i create under cn=Groups,dc=ad,dc=company,dc=com)
    2)Creating an access policy such that when a user is created in OIM, he is provisioned to two additional groups in OID, say I've created two custom groups in OIM and attached membership rules to them. Now when i create a user satisfying the two membership rule,he is assigned to those two OIM groups and provisioned to cn=users,dc=ad,dc=company,dc=com and cn=group1,cn=Groups,dc=ad,dc=company,dc=com and cn=group2,dc=ad,dc=company,dc=com.
    Also i want to populate those OID groups into a child table and create their lookups in Process form
    Please help me materialise and understand these concepts.
    The OID Lookup Recon task for group is running fine, lookup.oid.group is populated with values.
    how those groups can be populated in process form child table(OID user group table).
    Edited by: Chhavi Saluja on Feb 12, 2010 12:51 AM

    As mentioned in my other post you can put these groups in access policy form and all the users assigned by this policy will get these groups. Any issue revert back.

  • PowerShell script cannot find user permissions given directly (can find if permissions given in a group) - Please help.

    Hi there,
    I need to find ALL SharePOint sites/subsites/locations where "Domain\john" has any level of access. 
    Following script works if the permissions were given to Domain\john via a group - but this does not work if the permissions were given directly to the user (i.e. user is NOT part of the group).
    $weburl = "http://dev"
    Get-SPUser -web $weburl -Limit All | ?{$_.UserLogin -eq "Domin\john"} | select UserLogin, @{name="Url";expression={$_.ParentWeb.Url}}, @{name="Explicit given roles";expression={$_.Roles}}, @{name="Roles given via groups";expression={$_.Groups | %{$_.Roles}}},Groups | Out-String -Width 4096
    Help will be appreciated.
    Thank you.

    I don't really understand your request. It sounds like you just want to know the permissions per-user
    $weburl = "http://dev"
    Get-SPUser -web $weburl -Limit All | ?{$_.UserLogin} | select UserLogin, @{name="Url";expression={$_.ParentWeb.Url}}, @{name="Explicit given roles";expression={$_.Roles}}, @{name="Roles given via groups";expression={$_.Groups | %{$_.Roles}}},Groups | Out-String -Width 4096
    This will just return all the users and their permissions.
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

Maybe you are looking for

  • Does the registry fix file "SubInACL" work with Windows XP?

    I have been reading many suggestions from the Adobe website as well as the flash player forum to try and fix the problems I'm having with flash player.  I tried to uninstall and reinstall the flashplayer 10 software but get an error.  Then I read tha

  • My center button is not working on my ipad2

    The center button on my ipad2 stopped working.  Any ideas---please I need help

  • Help needed to connect dual monitors.

    Hi everyone. Here's my problem, I bought two Samsung SyncMaster 913v LCD TFT Displays. Both of these displays (since they aren't the digital LCD) connect the same way my old Sony Trinitron MultiscanG400 display connected, which I believe is the VGA c

  • Component cables & digital audio???

    I'm connecting my DVD player to my receiver, i want to use the 3 component (green,red,blue) for video and the digital coaxial (orange) for audio! So my question is, can I buy a component 5 cable set and use either the red or white for my digital audi

  • Developer OCA-to-OCP timing

    Good day, I received my OCA several years ago (in 2004) and just now finally have the motivation to continue on towards OCP. I'm a developer and I would be pursuing PL/SQL Developer certification. I'm wondering if there is a timline in which my OCA i