Max no of partitions

hello folks,
Please let me know the following..
1). Which are the different objetcs on which partitioning can be performed?
2). Is there any restrictions on the max no of partitions?
3). Can repartitioning can be performed on any other BI objects except the cube?
4). On which BW objetcs remodelling can be done?
Thanks,
Suyog.

Hi,
Partitions:Usually 20-30 partitions are per F table are suposed to be optimal for one load a day and 30 days a month scenario.
If there are high partitions system can have long run time in reporting, creating statistics, droping indexes etc.Pls chk  SAP Note 590370 for this. Also pls chk this link;cube partitioning
Remodelling:
You can remodel cubes in which data is already loaded, and you want to change the structure without loosing data, you may insert, delete, replace a charecteristic or a key figure.The transaction code for remodelling is RSMRT.
http://help.sap.com/saphelp_nw04s/helpdata/en/58/85e5414f070640e10000000a1550b0/frameset.htm
/people/mallikarjuna.reddy7/blog/2007/02/06/remodeling-in-nw-bi-2004s
Regards
CSM Reddy

Similar Messages

  • Finding the max value using partition by

    Hi
    I've the following requirement where i need to select the max value from the data
    WITH T AS
    (SELECT 48003 ID ,'SPR' RTNG_TP_CD , 'INS' RL_CD ,'A-' RAT_CD FROM DUAL UNION ALL
    SELECT 48003 , 'SLNG' ,'INS','A-' FROM DUAL)
    SELECT distinct  ID, RTNG_TP_CD,RL_CD,MAX(RAT_CD)  over (partition by id) RT_CD
    FROM T
    For a single id if there are 2 RTNG_TP_CD then select the max(rat_cd) by displayin rtng_tp_cd =SLNG
    Expected Output
    48003 , SLNG , INS , A-Thank You

    WITH T AS
    (SELECT 48003 ID ,'SPR' RTNG_TP_CD , 'INS' RL_CD ,'A-' RAT_CD FROM DUAL UNION ALL
    SELECT 48003 , 'SLNG' ,'INS','A-' FROM DUAL)
    SELECT distinct ID,decode((select count(*) from t where id=t.id),1,RTNG_TP_CD, 'SLNG') RTNG_TP_CD,RL_CD,MAX(RAT_CD) over (partition by id) RT_CD
    FROM T

  • Max files per partition

    I am looking to find the max files per partition for MAC OS X Server (and if any differences occur in the XServe RAID) I see that the max file size is 2^63 my concern revolves arounds users with thousands of tiny files
    Thank You

    There is no 'per-partition' limit, it is defined by the format of the volume.
    For example, HFS+ has a theoretical maximum of 2,147,483,648 files (2^31 - not sure where you're seeing 2^63).
    However, in any case the limit is likely to be lower based on the number of allocation blocks on the volume. Since every file will consume at least one block the actual limit is really (number of (allocation blocks -1) which is still a significant number.
    The reality, though, is that the disk limit is not likely to be your problem. The Finder becomes an absolute dog when there are many thousands of files in a directory. If you're trying to view these files in the Finder you'll find the limit is in the low thousands before performance degrades. Note that this limit only applies to files in a single directory and that if you're using a hierarchy of folders you can overcome this problem.
    Non-GUI tools have a better time with it. I have one directory on disk with almost 100,000 files on it and the Finder is the only app that has an issue with it.

  • Over partition: how to use to return the max of two columns

    For each unique id, I want to select the value of col2 in the record with the most recent date.
    When the rows with the same IDs have the same dates, I want the max value from col2.
    I want one row for each ID, but I'm getting two rows for ID 3333333.
    with data as
    select 1111111 as id, 'a' as col2, to_date('01-JAN-09','dd-mon-yyyy') as the_date from dual union all
    select 2222222 as id, 'b' as col2, to_date('02-JAN-09','dd-mon-yyyy') as the_date from dual union all
    select 2222222 as id, 'c' as col2, to_date('03-JAN-09','dd-mon-yyyy') as the_date from dual union all
    select 2222222 as id, 'd' as col2, to_date('04-JAN-09','dd-mon-yyyy') as the_date from dual union all
    select 3333333 as id, 'e' as col2, to_date('05-JAN-09','dd-mon-yyyy') as the_date from dual union all
    select 3333333 as id, 'f' as col2, to_date('05-JAN-09','dd-mon-yyyy') as the_date from dual
    select id, col2, the_date
    from
    select id, the_date, col2, max(the_date) over (partition by id) as max_the_date, max(col2) over (partition by col2) as max_col2
    from data
    where the_date = max_the_date and col2 = max_col2 order by id
    Expecting this:
    ID     COL2     THE_DATE
    1111111     a     1/1/0009
    2222222     d     1/4/0009
    3333333     f     1/5/0009
    but I'm getting 2 rows for ID 3333333
    Any suggestions?

    TRy this code without subquery
    SELECT   ID, MAX (the_date)KEEP (DENSE_RANK LAST ORDER BY the_date),
             MAX (col2)KEEP (DENSE_RANK LAST ORDER BY the_date)
        FROM DATA
    GROUP BY ID
    ORDER BY ID
    SQL> WITH DATA AS
      2       (SELECT 1111111 AS ID, 'a' AS col2,
      3               TO_DATE ('01-01-2009', 'dd-mm-yyyy') AS the_date
      4          FROM DUAL
      5        UNION ALL
      6        SELECT 2222222 AS ID, 'b' AS col2,
      7               TO_DATE ('02-01-2009', 'dd-mm-yyyy') AS the_date
      8          FROM DUAL
      9        UNION ALL
    10        SELECT 2222222 AS ID, 'c' AS col2,
    11               TO_DATE ('03-01-2009', 'dd-mm-yyyy') AS the_date
    12          FROM DUAL
    13        UNION ALL
    14        SELECT 2222222 AS ID, 'd' AS col2,
    15               TO_DATE ('04-01-2009', 'dd-mm-yyyy') AS the_date
    16          FROM DUAL
    17        UNION ALL
    18        SELECT 3333333 AS ID, 'e' AS col2,
    19               TO_DATE ('05-01-2009', 'dd-mm-yyyy') AS the_date
    20          FROM DUAL
    21        UNION ALL
    22        SELECT 3333333 AS ID, 'f' AS col2,
    23               TO_DATE ('05-01-2009', 'dd-mm-yyyy') AS the_date
    24          FROM DUAL)
    25  SELECT   ID, MAX (the_date)KEEP (DENSE_RANK LAST ORDER BY the_date ),
    26           MAX (col2)KEEP (DENSE_RANK LAST ORDER BY the_date )
    27      FROM DATA
    28      group by id
    29  ORDER BY ID;
            ID MAX(THE_DA M
       1111111 2009-01-01 a
       2222222 2009-01-04 d
       3333333 2009-01-05 f
    SQL> Edited by: Salim Chelabi on 2009-03-05 11:49
    Edited by: Salim Chelabi on 2009-03-05 11:50

  • How to Get the min,max and original values in a single query

    Hi,
    I have a task where in i have to the min , max and the original values of  a data set .
    I have the data like below and i want the target as well as mentioned below
    SOURCE
    DATASOURCE
    INTEGRATIONID
    SLOT_DATE
    SLOT1
    SLOT2
    SLOT3
    SLOT4
    SLOT5
    SLOT6
    SLOT7
    SLOT8
    SLOT9
    SLOT10
    1
    101
    201111
    100
    100
    200
    100
    100
    100
    300
    300
    300
    300
    1
    101
    2011112
    200
    200
    200
    200
    100
    100
    100
    100
    200
    300
    TARGET
    DATASOURCE
    INTEGRATIONID
    SLOT_DATE
    SLOT_VALUE
    SLOT MIN
    SLOT_MAX
    SLOT NUMBER
    1
    101
    201111
    100
    1
    2
    SLOT1
    1
    101
    201111
    100
    1
    2
    SLOT2
    1
    101
    201111
    200
    3
    3
    SLOT3
    1
    101
    201111
    100
    4
    6
    SLOT4
    1
    101
    201111
    100
    4
    6
    SLOT5
    1
    101
    201111
    100
    4
    6
    SLOT6
    1
    101
    201111
    300
    7
    10
    SLOT7
    1
    101
    201111
    300
    7
    10
    SLOT8
    1
    101
    201111
    300
    7
    10
    SLOT9
    1
    101
    201111
    300
    7
    10
    SLOT10
    1
    101
    2011112
    200
    1
    4
    SLOT1
    1
    101
    2011112
    200
    1
    4
    SLOT2
    1
    101
    2011112
    200
    1
    4
    SLOT3
    1
    101
    2011112
    200
    1
    4
    SLOT4
    1
    101
    2011112
    100
    5
    8
    SLOT5
    1
    101
    2011112
    100
    5
    8
    SLOT6
    1
    101
    2011112
    100
    5
    8
    SLOT7
    1
    101
    2011112
    100
    5
    8
    SLOT8
    1
    101
    2011112
    200
    9
    9
    SLOT9
    1
    101
    2011112
    300
    10
    10
    SLOT10
    e
    so basically i would first denormalize the data using the pivot column and then use min and max to get the slot_start and slot_end.
    But then i
    can get the min and max ... but not the orignal values as well.
    Any thoughts would be appreciated.
    Thanks

    If you want to end up with one row per slot per datasource etc, and you want the min and max slots that have the same value as the current slot, then you probably need to be using analytic functions, like:
    with t as
    (SELECT 1 datasource,101    INTEGRATIONID, 201111     slotdate, 100    SLOT1, 100        SLOT2,    200    slot3, 100    slot4, 100    slot5, 100    slot6, 300    slot7, 300    slot8, 300    slot9, 300 slot10 FROM DUAL  union all
    SELECT 1,    101,    2011112,    200,    200,    200,    200,    100,    100,    100,    100,    200,    300 FROM DUAL),
    UNPIVOTED AS
    (SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,1 SLOT,SLOT1 SLOT_VALUE
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,2 SLOT,SLOT2
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,3 SLOT,SLOT3
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,4 SLOT,SLOT4
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,5 SLOT,SLOT5
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,6 SLOT,SLOT6
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,7 SLOT,SLOT7
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,8 SLOT,SLOT8
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,9 SLOT,SLOT9
    FROM T
    UNION ALL
    SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,10 SLOT,SLOT10
    FROM T)
    select DATASOURCE,INTEGRATIONID,SLOTDATE,slot,slot_value,min(slot) OVER (partition by datasource,integrationid,slotdate,rn) minslot,
        max(slot) OVER (partition by datasource,integrationid,slotdate,rn) maxslot
    FROM   
      select DATASOURCE,INTEGRATIONID,SLOTDATE,max(rn) over (partition by datasource,integrationid,slotdate order by slot) rn,slot,slot_value
      FROM
        (SELECT DATASOURCE,INTEGRATIONID,SLOTDATE,slot,slot_value,
              case when row_number() over (partition by datasource,integrationid,slotdate order by slot) = 1 or
              lag(slot_value) over (partition by datasource,integrationid,slotdate order by slot) <> slot_value
                  then row_number() over (partition by datasource,integrationid,slotdate order by slot)
                  ELSE null
                  END rn
        from unpivoted
    order by DATASOURCE,INTEGRATIONID,SLOTDATE,slot 

  • What is the significance of Hash Partition ?

    Hi All,
    First time i am going to implement Hash partition as well as subpartition also.before implementing i have some query regarding that.
    1.What is the Max no. of partition or sub partition we can specify and default ?
    2.How do we know whch data comes under whch Hash partition ? i mean suppose incase of range partition based on specified range we are able to know what data comes under what partition. Same incase of List partition.
    Does anyone have any idea.
    Thanks n advance.
    Anwar

    1. Take a look here : http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/limits003.htm
    2. Take a look here : Re: Access to HASH PARTITION
    Nicolas.
    Correction of link
    Message was edited by:
    N. Gasparotto

  • Partition Table Looks Different Between OSX and Windows 7

    Hey all,
    I recently replaced the hard drive on my 2007 iMac, going from the 320GB drive to a 1 TB drive. It actually worked! The previous drive was failing in very odd ways, though booting into the Windows side (more on dual boot later) always seemed to work, and S.M.A.R.T. always reported that the physical drive seemed OK.
    The previous drive (320 GB) had around 200GB devoted to OSX and 100GB partitioned off for a working Windows 7 installation (custom installed x64 Win7 Ultimate). I had the Windows system image backed up to my NAS, and had a Windows system bootable disc to restore that image.
    After replacing the drive (and almost crying that I had actually done it right), I first restored OSX from a Time Machine backup, and let it take the full 1TB of space as Journalled HFS+. Then, I used Disk Utility to shrink OSX down to 500GB, and created a second partition (formatted to NTFS) with the remaining 500GB.
    Now, restoring a Windows system image is an odd thing, as it tries to do a lot of partition work as opposed to simply restoring the Windows install to a partition. I tried Macrium Reflect first (made a backup in that, too), and it looked like it was going to let me restore to the second partition. It completed the restore...and the entire hard drive was hosed. Partitions had been moved, renamed, resized, and nothing was bootable. I had to use Recovery from an external USB thumb drive to go back to the single, full-drive install of OSX.
    Then I tried again. Made the second NTFS partition and used the basic Windows System Restore disk to restore from the standard system image I had on the NAS. I was not expecting this to work. But it did. Windows started showing up in Startup Manager when "option" was pressed on bootup, and both OSX and Windows booted properly and ran fine. This is where I (finally) get to the supreme oddities:
    OSX Disk Utility still reports two 500GB partitions, one for OSX and one for Windows.
    In OSX the Windows partition shows as having NO DATA on it. Not sure what would happen if I tried to write a file to it when mounted, but there is no data on it when viewed from OSX (I was always able to see the Windows files when I mounted that partition on the previous drive).
    The Windows partition does not show up as a valid bootable system in System Prefs --> Startup Disk (naturally, I suppose, since OSX doesn't think there is anything there).
    From the WINDOWS side, Windows still sees the old partition table: 200GB for the "unknown" HFS partition, and then the rest of the space can be devoted to Windows (started as 100GB, but I was ablt to expand it to use the remaining ~750GB!).  Windows thinks it can have 750GB of space even though I know its partition is only 500GB in size!
    Windows cannot see the OSX HFS partition data using HFSExplorer. It CAN see the HFS partition on the attached backup drive (the drive I use for Time Machine).
    GParted (a partition program on a Linux bootabld CD-ROM) shows the same partitions as OSX Disk Utility (2x500GB), and also thinks the Windows NTFS partition is empty (all space reports as "unused").
    Did I mention both OSX and Windows work fine???
    There are, of course, two other partitions on the drive: the first partition is the 200MB one I always see (EFI/GUID portion?), and then between the HFS and NTFS partitions is the 600MB recovery partition (which also shows at option-pressed boot time). OSX, GParted, and Windows see all four partitions, and in the same order. It is just that Windows sees the wrong sizes, and OSX cannot see any data in the Windows partition.
    Surely this is all going to break spectacularly at some point, isn't it? What if I ever did write a file to the Windows side from OSX, or what if OSX starts taking more space than the 200GB Windows thinks is the max for that partition? What if I try to make Windows use more than 500GB because it thinks it has almost 800GB to use? What if I defrag the Windows drive?
    I had no idea a partition table could look this goofy and yet still have everything be bootable and workable. Is there something I can do to get everything in sync? Basically, I am assuming I need to get Windows to do some low-level kung fu in Disk Manager in order to properly get everything lined up with the "right" partitions as reported by both GParted and OSX Disk Utility. But how do I do that?
    By the way, any ideas that totally nuke the drive and start from scratch are completely fine (if it seems like they are doing something different enough that I'd give it a try). I have good backups of both OSX and Windows and have restored them about a half dozen times already as I dealt with the previous failing hard drive and with trying to get dual-boot working again. Not to mention, this iMac is now my secondary machine to the new Mac Mini I got a couple weeks back when I wasn't sure how much more life I was going to get from this 6+ year old iMac.
    Thanks for listening to me ramble about this very odd issue, and a huge THANK YOU in advance to anyone who has ideas to help.
    Thanks,
    sutekh138

    Update:
    I am pretty sure the issue is a simple GPT/MBR discrepancy.
    I installed rEFIt and used it's partitioning tool (gptsync built in) upon bootup. It was able to show the GPT table and the MBR table, but it thinks the second partition of the drive (the Mac OSX bootable partition) is "extended" in the MBR table and says "will not touch this disk."
    However, it does look like an MBR sync should be straightforward, as there four partitions in the GPT table and four in the MBR (and MBR allows a max of four, AFAIK). I just need gptsync to relax some rules. I found a link to a supposedly newer version of gptsync compiled for OSX, so I will try that later.
    First, I will try Partition Wizard, a free tool I found for the Windows side. It has a "Repair MBR" option that I would have tried last night if I weren't running a new Windows Image Backup in case all of this goes haywire.  *smile*  The PW tool also has an option to change the MBR over to GPT entirely. That might work, but then I am not sure Windows 7 will boot (from what I read, x64 Win7 running on EFI-enabled hardware should work, but who knows).
    Anyway, I will try the following things, in order, until something works, when I get home tonight:
    From Windows, run Partition Wizard and try "Repair MBR".
    From OSX, download recent gptsync and try to run it.
    From Windows, use Partition Wizard to do a full MBR --> GPT conversion.
    Nuke the Windows partition in OSX Disk Utility, expand the HFS partition to take up the whole drive, and then add a Windows-bootable partition via Boot Camp-ish command line commands (diskutil). Because if nothing else works, I have to assume I just created the partitions wrong in the first place such that a Windows restore miraculously works, but the partition weirdness is just a timebomb waiting to happen.
    Finally, if none of the above work, I'll just get things back to the way they now work and wait for the timebomb to (possibly never) go off.  *smile*
    I'll update this thread if I get something figured out, in case anyone else stumbles upon it...
    Thanks,
    sutekh138

  • Picking a Max value row out of a group of rows.

    Hi,
    I'm using Oracle 10.2.0.4.0
    For some reason I can't come up with a way to pick out a simple row that contains the max date value out of a group of sub group of rows. The following rows are one group of the result of a complex view ordered by ACCOUNT_NUMBER. I'm just showing the first group for Demo Purposes.
    CUSTOMER_NAME          ACCOUNT_NUMBER     BOOKED_DATES     OUTSTANDING_APPROVALS     BOOKED_NOT_BILLED         SALES
    ABC company, LLC     114943          05/22/2008                   11:17:05           100,072.43          100,072.43
    ABC company, LLC     114943          06/30/2008                   15:12:29           129,956.00          129,956.00
    ABC company, LLC     114943          07/30/2008                   15:57:16           10,957.00          10,957.00This is just the first of many groups in this view. I just need a simple way to select the row with the max BOOKED_DATES. I've tried everything I could think of but the other two rows are not going away. MAX(BOOKED_DATES) is not working in the HAVING section. I just want my out output to be the rows out of each group with the most recent BOOKED_DATES.
    Therefor , my output would be
    CUSTOMER_NAME          ACCOUNT_NUMBER     BOOKED_DATES     OUTSTANDING_APPROVALS     BOOKED_NOT_BILLED         SALES
    ABC company, LLC     114943          07/30/2008                   15:57:16           10,957.00          10,957.00for ACCOUNT_NUMBER 114943. For the truly curious, the query is below. I'm sure the solution is simple but not to me this day. Maybe it's a Monday thing.
    Thanks in Advance.
    select  distinct
    party.party_name CUSTOMER_NAME, --"Customer Name"
    cust_acct.account_number ACCOUNT_NUMBER,--"Account Number"
    max(h.BOOKED_DATE)  BOOKED_DATES,-- "Booked Dates",
    osa.OUTSTANDING_SALE_AMT    OUTSTANDING_APPROVALS,--"Outstanding Approvals",
    ola2.BOOKED_NOT_BILLED                                     BOOKED_NOT_BILLED,
    --ola.line_id,
    --h.header_id,
    sum(nvl(ola.ORDERED_QUANTITY,0) * nvl(ola.UNIT_LIST_PRICE,0))   SALES,
    CASE
       WHEN
       invoiced_amt_info.TERMS = 'Current'
        THEN invoiced_amt_info.CURRENT_INV  
       ELSE NULL
    END  "CURRENT_IA",--"Current",
    CASE
       WHEN
       invoiced_amt_info.TERMS = 'Current'
        THEN invoiced_amt_info.CURRENT_TAX 
       ELSE NULL
    END CURRENT_TAX,--"Current Tax",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '1-30 days'
        THEN invoiced_amt_info.CURRENT_INV 
       ELSE NULL
    END     LT_30_DAYS,--  "1-30 Days",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '1-30 days'
        THEN invoiced_amt_info.CURRENT_TAX  
       ELSE NULL
    END     LT_30_DAYS_TAX,-- "1-30 Days Tax",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '31-60 days'
        THEN invoiced_amt_info.CURRENT_INV 
       ELSE NULL 
    END     LT_60_DAYS,-- "1-60 Days",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '31-60 days'
        THEN invoiced_amt_info.CURRENT_TAX
       ELSE NULL
    END     LT_60_DAYS_TAX,--"1-60 Days Tax",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '61-90 days'
        THEN invoiced_amt_info.CURRENT_INV  
       ELSE NULL
    END     LT_90_DAYS,-- "1-90 Days",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '61-90 days'
        THEN invoiced_amt_info.CURRENT_TAX 
       ELSE NULL
    END     LT_90_DAYS_TAX,-- "1-90 Days Tax",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '90+ days'
        THEN invoiced_amt_info.CURRENT_INV  
       ELSE NULL 
    END     MT_90_PLUS_DAYS,-- "90+ Days",
    CASE
       WHEN
       invoiced_amt_info.TERMS = '90+ days'
        THEN invoiced_amt_info.CURRENT_TAX
       ELSE NULL
    END     MT_90_PLUS_DAYS_TAX,--"90+ Days Tax",
    uc.UNAPPLIED_CASH UNAPPLIED_CASH--"Unapplied Cash"
    FROM
    oe_order_headers_all        h,
    hz_cust_accounts            cust_acct,
    hz_parties                  party,
    hz_customer_profiles        cust_prof,
    oe_order_lines_all ola,
    select l.HEADER_ID HEADER_ID,
    l.sold_to_org_id SOLD_TO_ORG_ID,
    sum(nvl(l.ORDERED_QUANTITY,0) * nvl(l.UNIT_LIST_PRICE,0)) BOOKED_NOT_BILLED
    from
    oe_order_lines_all l
    where
        l.BOOKED_FLAG <> 'N'
    AND l.FLOW_STATUS_CODE <> 'CANCELLED'
    AND l.INVOICE_INTERFACE_STATUS_CODE <> 'NO'
    group by l.HEADER_ID, l.sold_to_org_id
    ) ola2,
    select INV_AMT.aginglayer, INV_AMT.aging TERMS, sum(INV_AMT.due_amount) CURRENT_INV, INV_AMT.CUSTOMER_ID,--due_amount,--invoiced ammount Currrent
              sum(INV_AMT.tax_amount) CURRENT_TAX --tax_amount
               from (
                    select  
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , 'Current' aging
                          , 1 aginglayer
                          , 1 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) < 1
                       and ps.customer_id = c.customer_id
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID
                    union
                    select   
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID                     
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , '1-30 days' aging
                          , 2 aginglayer
                          , 2 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) >= 1
                       and trunc(sysdate - ps.due_date) <= 30
                       and ps.customer_id = c.customer_id
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID                     
                    union
                    select  
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID                     
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , '31-60 days' aging
                          , 3 aginglayer
                          , 3 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) > 30
                       and trunc(sysdate - ps.due_date) <= 60
                       and ps.customer_id = c.customer_id
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID
                    union
                    select  
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID                     
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , '61-90 days' aging
                          , 4 aginglayer
                          , 4 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) > 60
                       and trunc(sysdate - ps.due_date) <= 90
                       and ps.customer_id = c.customer_id
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID                        
                    union
                    select  
                            c.customer_name
                          , c.customer_number
                          , c.CUSTOMER_ID                     
                          , sum(ps.amount_due_remaining) due_amount
                          , sum(ps.tax_remaining) tax_amount
                          , '90+ days' aging
                          , 5 aginglayer
                          , 5 showord
                     from ra_customers c
                          , ar_payment_schedules_all ps
                          , ra_customer_trx_all trx
                          , ra_cust_trx_types_all types
                     where ps.status = 'OP'
                       and ps.class <> 'PMT'
                       and trunc(sysdate - ps.due_date) > 90
                       and ps.customer_id = c.customer_id
                       and trx.customer_trx_id = ps.customer_trx_id
                       and types.cust_trx_type_id = trx.cust_trx_type_id
                       and types.name <> 'CSG-Conversion Pmt'
                       and types.org_id= 1
                     group by c.customer_name
                             , c.customer_number
                             , c.CUSTOMER_ID
                    ) INV_AMT
                 group by aginglayer, aging, showord, INV_AMT.CUSTOMER_ID
    ) invoiced_amt_info,
    select   ra_cust.customer_name CUSTOMER_NAME, ra_cust.customer_number CUSTOMER_NUMBER, ra_cust.customer_id CUSTOMER_ID,
                     sum(pay_sched.amount_due_remaining) UNAPPLIED_CASH
               from  ra_customers ra_cust
                    , ar_payment_schedules_all pay_sched
               where
                 pay_sched.status = 'OP'
                 and pay_sched.class = 'PMT'
                 and pay_sched.due_date > trunc(sysdate - 365)
                 and pay_sched.customer_id = ra_cust.customer_id
               group by ra_cust.customer_name, ra_cust.CUSTOMER_NUMBER, ra_cust.CUSTOMER_ID
    ) uc,
    select   qh.cust_account_id CUST_ACCOUNT_ID,    sum(qh.total_quote_price) OUTSTANDING_SALE_AMT
    from ASO_QUOTE_HEADERS_ALL qh,ASO_QUOTE_STATUSES_TL st
    where st.quote_status_id = qh.quote_status_id
    and st.meaning ='Credit Hold'
    group by qh.cust_account_id
    ) osa          
    Where 
         h.HEADER_ID = ola.HEADER_ID
    AND h.HEADER_ID = ola2.HEADER_ID
    AND ola.sold_to_org_id = cust_acct.cust_account_id(+)
    AND ola2.sold_to_org_id = ola.sold_to_org_id(+)
    AND cust_acct.party_id = party.party_id(+)
    AND cust_acct.CUST_ACCOUNT_ID = cust_prof.CUST_ACCOUNT_ID(+)
    AND cust_prof.party_id = party.party_id
    AND cust_prof.CUST_ACCOUNT_ID = invoiced_amt_info.CUSTOMER_ID(+)
    AND cust_prof.CUST_ACCOUNT_ID = uc.CUSTOMER_ID(+)
    AND cust_prof.CUST_ACCOUNT_ID = osa.CUST_ACCOUNT_ID(+)
    group by  party.party_name, cust_acct.account_number, invoiced_amt_info.TERMS, osa.OUTSTANDING_SALE_AMT,
    ola2.BOOKED_NOT_BILLED,
    invoiced_amt_info.CURRENT_INV,
    invoiced_amt_info.CURRENT_TAX, uc.UNAPPLIED_CASH
    order by party.party_name

    Example
    --Sample Data
    SQL>select deptno, empno, sal,
      2     max(sal) over ( partition by deptno order by deptno) mv
      3* from emp
    SQL> /
        DEPTNO      EMPNO        SAL         MV
            10       7782       2450       5000
            10       7839       5000       5000
            10       7934       1300       5000
            20       7566       2975       3000
            20       7902       3000       3000
            20       7876       1100       3000
            20       7369        800       3000
            20       7788       3000       3000
            30       7521       1250       2850
            30       7844       1500       2850
            30       7499       1600       2850
            30       7900        950       2850
            30       7698       2850       2850
            30       7654       1250       2850
    14 rows selected.
    SQL>select * from
      2  (
      3  select deptno, empno, sal,
      4     max(sal) over ( partition by deptno order by deptno) mv
      5  from emp
      6* ) where sal = mv
    SQL> /
        DEPTNO      EMPNO        SAL         MV
            10       7839       5000       5000
            20       7902       3000       3000
            20       7788       3000       3000
            30       7698       2850       2850SS

  • MAX DateTime Not working

      SELECT MAX(DateTimeAdded) OVER(PARTITION BY PatientID ORDER BY DateTimeAdded)as DateTimeAdded
        FROM ClinicalVitalGroup CVG_D
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'OVER'.
    Why is this not working???

    GROUP BY looks for unique value combinations of entire columns specified, so when you add one more column the column combination changes and it looks for the unique combination of all columns together. So combination of values for PatientID and
    ClientVitalGroupID  will still be unique though if you look at PatientID individually you
    may see duplicates.
    See this small illustration to understand it
    declare @t table
    Col1 int,
    Col2 int,
    Col3 varchar(10)
    insert @t
    select 1,2,'Test' union all
    select 1,3,'qwerty' union all
    select 1,3,'blah blah' union all
    select 1,4,'jbj' union all
    select 2,6,'jkhk' union all
    select 2,8,'kkjkl' union all
    select 2,8,'kljklj' union all
    select 2,11,'kklljl'
    select Col1,COUNT(*) AS Cnt
    from @t
    group by Col1
    The above code will return just two records as you've only two unique values for COl1 field (1 and 2)
    See output below
    Col1 Cnt
    1 4
    2 4
    Now add col2 also to group by and see
    You will get 6 records as there are six unique combinations for Col1 and Col2
    ie (1,2),(1,3),(1,4),(2,6),(2,8),(2,11)
    see
    declare @t table
    Col1 int,
    Col2 int,
    Col3 varchar(10)
    insert @t
    select 1,2,'Test' union all
    select 1,3,'qwerty' union all
    select 1,3,'blah blah' union all
    select 1,4,'jbj' union all
    select 2,6,'jkhk' union all
    select 2,8,'kkjkl' union all
    select 2,8,'kljklj' union all
    select 2,11,'kklljl'
    select Col1,Col2,COUNT(*) AS Cnt
    from @t
    group by Col1,Col2
    The output is
    Col1 Col2 Cnt
    1 2 1
    1 3 2
    1 4 1
    2 6 1
    2 8 2
    2 11 1
    If you analyze any one column again (Col1 or Col2) in above output you can see the value duplicating as GROUP BY just ensures the
    full combination of values being unique rather than the individual values themselves
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Min,Max for a time Range and Sum of Records for the last date/time

    Hi All,
    I have a table with the following structure/data:
    create table  Events   (
                                        [EventID]       
    int                   NOT NULL,
                                        [Title]            
    nvarchar(200)  NOT NULL,
                                        [SourceName]  nvarchar(20)    NOT NULL,
                                        [Type]             
    int                  NOT NULL,
                                        [eDate]           
    datetime
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S07', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S08', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S09', 3,'2014-01-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S010', 3,'2014-01-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-01-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-01-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-01-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-02-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S02', 3,'2014-02-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-02-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-02-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-02-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-02-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S01', 3,'2014-03-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S02', 3,'2014-03-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S03', 3,'2014-03-01 00:00:00.000')
    insert into Events values(100, 'Event 1', 'S04', 3,'2014-03-01 00:00:00.000')
    insert into Events values(101, 'Event 2', 'S05', 3,'2014-03-01 00:00:00.000')
    insert into Events values(102, 'Event 3', 'S06', 3,'2014-03-01 00:00:00.000')
    And I wrote the following query:
     select EventID as [Event ID],
           Title, 
           count(distinct(SourceName)) as [Instances], 
           Type,
           min(eDate) as  [First Detected],
           max(eDate) as [Last Detected],
           datediff(d,min(eDate),max(eDate)) as [Delta (days)]
    from  Events
    where type = 3
    group by EventID, Title, Type
    having max(eDate) <> min(eDate)
       and max(eDate) =(select top 1 eDate from Events order by eDate desc)
    and I get the following results (see the instance number)
    Event ID Title         Instances Type First Detected                      Last Detected                    
       Delta (days)
    =============================================================================================================================
    100         Event 1         5         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000    
    59
    101         Event 2        
    3         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     59
    102         Event 3        
    2         3    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     59
    This is normal for this query however what I need to do is a little different.
    In other words, while I need to show when we recorded a specific event first and last time,
    I need to display the results for the last date/time when it was recorded. 
    For example what I need to provide should look like this:
    Event ID  Title                Instances        Type       First Detected                    
    Last Detected                          Delta (days)
    =============================================================================================================================
    100         Event 1            2                   3           
    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000      59
    101         Event 2            2                   3           
    2014-01-01 00:00:00.000     2014-03-01 00:00:00.000      59
    102         Event 3           
    2                   3            2014-01-01 00:00:00.000     2014-03-01 00:00:00.000     
    59
    Could you please help me to fix this query?
    TIA,
    John

    ;With cte As
    (Select EventID as [Event ID],
    Title,
    SourceName,
    Type,
    min(eDate) Over(Partition By EventID, Title, Type) as [First Detected],
    max(eDate) Over(Partition By EventID, Title, Type) as [Last Detected],
    eDate,
    datediff(d,min(eDate) Over(Partition By EventID, Title, Type),max(eDate) Over(Partition By EventID, Title, Type)) as [Delta (days)],
    max(eDate) Over() As MaxEDate
    from Events
    where type = 3)
    Select [Event ID],
    Title,
    COUNT(Distinct SourceName) As Instances,
    Type,
    [First Detected],
    [Last Detected],
    [Delta (days)]
    From cte
    Where eDate = MaxEDate And [First Detected] <> [Last Detected]
    Group By [Event ID],
    Title,
    Type,
    [First Detected],
    [Last Detected],
    [Delta (days)];
    Tom
    P.S. Thanks for providing the DDL and data.  That is always very helpful.

  • Help in query to get the max(date)

    Hi I have query like below and based on the query I get the following results,
    SELECT a.UsageId,a.product,ProductDate
    FROM dbo.table1 a
    JOIN dbo.table2 b ON a.SID= b.SID
    JOIN dbo.table3 c ON b.CID = c.CID
    UsageId        Product          UsageDate
    1 Yellow 2014-01-01
    2 Yellow 2014-01-02
    3 Yellow 2014-01-03
    4 Yellow 2014-01-04
    5 Red 2014-01-01
    6 Red 2014-01-02
    7 Blue 2014-01-03
    8 Blue
    2014-01-04
    Now I want to add a new column which gives me the Max(UsageDate) of the column Prdouct last Usage.
    UsageId        Product          UsageDate          Max(UsageDate)
    1 Yellow
    2014-01-01          2014-01-04
    2 Yellow
    2014-01-02    2014-01-04
    3 Yellow
    2014-01-03          2014-01-04
    4 Yellow
    2014-01-04          2014-01-04
    5 Red 2014-01-01          2014-01-02 
    6 Red 2014-01-02          2014-01-02
    7 Blue
    2014-01-03          2014-01-04
    8 Blue
    2014-01-04          2014-01-04

    Simply use:
    SELECT a.UsageId,a.product,ProductDate, MAX(ProductDate) OVER (PARTITION BY a.ProductID) as [Latest Product Usage Date]
    FROM dbo.table1 a
    JOIN dbo.table2 b ON a.SID= b.SID
    JOIN dbo.table3 c ON b.CID = c.CID
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Group by and over partition.

    Hi to everybody....
    i ahev a table like this:
    id name salary
    1 John 1000
    2 Tom 1300
    3 Alan 1400
    4 Mark 1800
    and i do a query like this:
    select max(salary) from table
    and i have 1800
    What i would like to have, is a query that return me the id, the name and the max salary.
    i can do
    select * from
    select max(salary) as max from table) AAA,
    table
    where AAA.max =table.salary.
    But i would like to do it in only one query using the group by expression and over partition statement.
    Thank's in advance to everybody!

    Flavio,
    You can use...
    sql> select max(sal) from emp;
      MAX(SAL)
          5000
    sql> select empno, ename, max(sal) over () from emp;
         EMPNO ENAME      MAX(SAL)OVER()
          7369 SMITH                5000
          7499 ALLEN                5000
          7521 WARD                 5000
          7566 JONES                5000
          7654 MARTIN               5000
          7698 BLAKE                5000
          7782 CLARK                5000
          7788 SCOTT                5000
          7839 KING                 5000
          7844 TURNER               5000
          7876 ADAMS                5000
         EMPNO ENAME      MAX(SAL)OVER()
          7900 JAMES                5000
          7902 FORD                 5000
          7934 MILLER               5000If you need to have the max per department , you just would need to add....
      1* select empno, ename, max(sal) over (partition by deptno) from emp
    sql> /
         EMPNO ENAME      MAX(SAL)OVER(PARTITIONBYDEPTNO)
          7782 CLARK                                 5000
          7839 KING                                  5000
          7934 MILLER                                5000
          7566 JONES                                 3000
          7902 FORD                                  3000
          7876 ADAMS                                 3000
          7369 SMITH                                 3000
          7788 SCOTT                                 3000
          7521 WARD                                  2850
          7844 TURNER                                2850
          7499 ALLEN                                 2850
         EMPNO ENAME      MAX(SAL)OVER(PARTITIONBYDEPTNO)
          7900 JAMES                                 2850
          7698 BLAKE                                 2850
          7654 MARTIN                                2850HTH,
    Rajesh.

  • MAX Function Not Giving Accurate Results

    Hello,
    I have the following sql
    select ename ,temp,max(ver) as rv from
    table
    WHERE id = 5000
    AND id2 = 8000
    group by ename ,tempProblem with the above is always gives two records, ideally it should give only one which should be max(ver).
    How can I resolve this issue?
    Regards

    I'm not sure whether you are looking this or not?
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.02
    satyaki>
    satyaki>
    satyaki>with tt
      2  as
      3    (
      4      select 'THOMAS' ename, 'HR-022' temp, 2 ver from dual
      5      union all
      6      select 'EDWARD', 'FIN-011', 1 from dual
      7      union all
      8      select 'JOHN', 'IT-055', 3 from dual
      9      union all
    10      select 'JOHN', 'IT-055', 1 from dual
    11      union all
    12      select 'JOHN', 'IT-055', 2 from dual
    13    )
    14  select k.ename,
    15         k.temp,
    16         k.ver
    17  from (
    18          select m.*,
    19                 max(ver) over(partition by m.ename,m.temp order by m.ename,m.temp) rn
    20          from tt m
    21       ) k
    22  where k.ver = k.rn;
    ENAME  TEMP           VER
    EDWARD FIN-011          1
    JOHN   IT-055           3
    THOMAS HR-022           2
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Max  date in analytic function

    I have records that has repeating load dates.
    I would like to pick the records that has the maximum load_dates.
    My source data looks like this -
    ( select 60589 as C_number, to_date('01/08/2012','DD/MM/YYYY') as load_dt from dual union all
    select 60768, to_date('01/08/2012','DD/MM/YYYY') from dual union all
    select 60888, to_date('01/08/2012','DD/MM/YYYY') from dual union all
    select 12345, to_date('01/09/2012','DD/MM/YYYY') from dual union all
    select 54321, to_date('01/09/2012','DD/MM/YYYY') from dual union all
    select 66666, to_date('01/10/2012','DD/MM/YYYY') from dual union all
    select 55555, to_date('01/10/2012','DD/MM/YYYY') from dual)
    I would like to pick records with the max load_dt that means
    C_number load_dt
    666666 01-Oct-12
    555555 01-Oct-12
    I have written an oracle analytic function but it's not working the way it should be -
    My query looks like this -
    select a.*
    from
    select
    c_number,
    load_dt,
    max(load_dt) over (partition by load_dt) as mx_dt
    from table_name
    where
    load_dt = mx_dt;
    It returns all the rows for some reason.
    Any help or guidance is highly appreciated
    PJ

    without analytical..
    with mydata as
    ( select 60589 as C_number, to_date('01/08/2012','DD/MM/YYYY') as load_dt from dual union all
    select 60768, to_date('01/08/2012','DD/MM/YYYY') from dual union all
    select 60888, to_date('01/08/2012','DD/MM/YYYY') from dual union all
    select 12345, to_date('01/09/2012','DD/MM/YYYY') from dual union all
    select 54321, to_date('01/09/2012','DD/MM/YYYY') from dual union all
    select 66666, to_date('01/10/2012','DD/MM/YYYY') from dual union all
    select 55555, to_date('01/10/2012','DD/MM/YYYY') from dual)
    select *
              from mydata
              where load_dt = (select max(load_dt) from mydata);

  • Problem with select max(FIELD)

    I have a table with the following fields:
    PARTID     ART_TYP     AEC     SERVICE     PLANT     STATUS
    4711     A     A     2     P     230
    4711     A     B     0     P     230
    4712     A     B     2     P     230
    4713     A     B     0     P     230
    I need a sqlscript where I get the records with MAX(SERVICE)
    In this example
    4711     A     A     2     P     230
    4712     A     B     2     P     230
    4713     A     B     0     P     230
    I tried this with:
    select distinct partid,
         art_typ,
         aec,
         max(service),
         plant,
         status
    from t_msltmp
    group by partid,art_typ,aec,plant,status
    But I get both records of partid=4711
    Can someone help me with this problem
    kind regards
    Menk Slot

    ROW_NUMBER() requires explicit ORDER BY clause in OVER:
    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/functions105a.htm#86312
    SQL> select partid, art_typ, aec, mx, plant, status
      2  from(select partid,
      3                art_typ,
      4                aec,
      5                max(service) over (partition by partid) mx,
      6                row_number() over (partition by partid order by service desc) rn
      7                plant,
      8                status
      9         from t_t)
    10  where rn = 1
    11  /
        PARTID A A         MX P     STATUS
          4711 A A          2 P        230
          4712 A B          2 P        230
          4713 A B          0 P        230Rgds.
    P.S.
    Another way to get this (more tedoius):
    SQL> select partid,
      2  max(art_typ) keep (dense_rank first order by service desc) art_typ,
      3  max(aec) keep (dense_rank first order by service desc) aec,
      4  max(service) service,
      5  max(plant) keep (dense_rank first order by service desc) plant,
      6  max(status) keep (dense_rank first order by service desc) status
      7  from t_t
      8  group by partid
      9  /
        PARTID A A    SERVICE P     STATUS
          4711 A A          2 P        230
          4712 A B          2 P        230
          4713 A B          0 P        230Message was edited by:
    dnikiforov

Maybe you are looking for