Continuation: need data grouped for every week

SELECT * FROM aetnah_file_emp_cust_hist
WHERE pctl_employee_seqnum= 133774This query returns too many rows.
Now my requirement is that I need to get the most recent contrib_amt from this table for every week based on date column CTL_INS_DTTM.
This column CTL_INS_DTTM stores data about when a row wass inserted into this table.
pctl_employee_seqnum CTL_INS_DTTM(MM/DD/YYYY) contrib_amt
133774 01/01/2009 100
133774 01/02/2009 200
133774 01/03/2009 300
133774 01/04/2009 400
133774 01/05/2009 500
133774 01/06/2009
133774 01/07/2009 700
133774 01/08/2009 800
133774 01/10/2009 900
133774 01/12/2009 1000
133774 01/13/2009 1100
133774 01/14/2009 1200
I will need 52 columns (1 year = 52 weeks) totally and the most recent data for each week.
Ex:
Desired output:
01/07/2009 01/14/2009 01/21/2009 01/28/2009
700 1200 NULL 200
SELECT pctl_employee_seqnum, CTL_INS_DTTM, contrib_amt
  FROM (
          SELECT pctl_employee_seqnum, CTL_INS_DTTM, contrib_amt, ROW_NUMBER() OVER(PARTITION BY TO_CHAR(CTL_INS_DTTM, 'WMONYYYY')ORDER BY CTL_INS_DTTM DESC) RNO
            FROM aetnah_file_emp_cust_hist
           WHERE pctl_employee_seqnum= 133774
WHERE rno = 1This code above is doing that but I need to transpose this row wise data into column wise as mentioned on Desired output.
Total # of columns:52
Apologize for opening a new thread.....please help on this transpose issue
Thank You All

Hi,
TO_CHAR (ctl_ins_dttm, 'WMONYYYY') will result in 59 or 60 groups per year, since all months (except February in common years) have (incomplete) 5th weeks.
If you want 52 equal-sized groups, then TO_CHAR (ctl_ins_dttm, 'WWYYYY') will get you closer. (You'll still have an incomplete week 53.)
To pivot those rows into one column, you can do something like:
SELECT  MAX (CASE WHEN TO_CHAR (ctl_ins_dttm, 'WW') = '01' THEN contrib_amt END)   AS week_01
,       MAX (CASE WHEN TO_CHAR (ctl_ins_dttm, 'WW') = '02' THEN contrib_amt END)   AS week_02
,       MAX (CASE WHEN TO_CHAR (ctl_ins_dttm, 'WW') = '03' THEN contrib_amt END)   AS week_03
,       ...If you want data (like "01/07/2009") as the columns headers, then you'll have to use dynamic SQL.

Similar Messages

  • How we create Schema group for every vendor?

    If we have multiple vendors/transporters, how you configure pricing procedure for each vendor what is the process of creating Schema group for every vendor?
    Thanks in advance
    Suresh

    hi suresh,
    you create Pricing procedure, and then you create Vendor schema group; and purchasing schea group.
    for your scenario you will create N number of vendor schema groups.
    follow this menu path:
    spro --> materials management --> purchasing --> conditions --> define price determination process --> Define schema determination --> define caluculation schema for standard purchase orders -->
    in that screen:
    you maintain entries in the combination of
    purchasing org schema group  -- vendor schema group -- pricing procedure.
    for your scenario, you maintain N number of vendor schema groups and assign it to procing procedure.
    hope this may help you,
    Regards
    srinivas

  • Group by date and print for every week

    Crystal defaults to using Sunday-Saturday as its weekly breakdown when grouping.  I need to group by week but need to show a Monday-Saturday week.  Any help will be appreciated.
    Thanks,
    John

    I figured it out. I grouped on a formula containing:
    datediff("ww",date(year(currentdate),1,1),{PR_GLDET.Pay_Date},crMonday)

  • How do you make the date change for every entry when inserting.

    Hello, I am making a daily vehicle inspection report for my truck and I would like to make a 7 day calendar but I would like to insert the date ie Monday Feb 22, 2010, Tuesday Feb 23, 2010 etc...and have it change for each day of the week. is there a way to do this? Also can you put an outline or a box around the 6 lines of text that you input.
    Thank you
    Ottoman

    Jerrold Green1 wrote:
    Ottoman,
    As Peter says, you can use a Table for this. You do not, however, need to enter two dates to fill with a series of dates. Dates are an exception to the general Fill rule. Just enter one, and fill down to get successive dates.
    Other exception available:
    a single cell is sufficient for every entries ending with a number :
    president1
    thief2
    king3
    behave this way.
    Durations behave like numbers : two cells are required.
    Yvan KOENIG (VALLAURIS, France) samedi 27 février 2010 18:20:29

  • Error when creating volume on data group for acfs

    Hi,
    I want to create ACFS file system on solaris SPARC system which is running solaris 10.9. I have created data group successfully but i get an error when i try to create volume.
    ASMCMD> volcreate -G OEMLIB -s 30G oemlibvol1
    ORA-15032: not all alterations performed
    ORA-15472: volume library cannot be loaded. Platform may not support volume creation. (DBD ERROR: OCIStmtExecute)
    i read that solaris 10.8 or more support acfs and my oracle grid software is also 11.2 higher.
    what could be the issue? Do i need to manually load drivers for ADVM? where are they located?

    Thanks
    Thanks for your input.
    We are missing the ACFS binaries after we installed 11.2.0.1 GRID and Database on Solaris 10 Update 8.
    The following are missing from the GRID_HOME/bin:
    Acfsload, acfsroot, acfsdriverstate, acfsregitrymount, acfssinglefsmount.
    I see these in 11.2.0.1 version of a LINUX install in our datacenter but don’t see it in our Solaris Install.

  • Load a swatch group for every file, everytime.

    How do I have a custom swatch group be available in the swatch palette for every file I open (new files, old files... everything)?  This includes opening Windows Meta Files and Enhanced Meta Files.
    Thanks,
    Adrian.
    Message was edited by: ( Adrian M. )

    Sorry about that. Let me explain my exact situation.  I have a huge load of windows metafiles and enhanced metafiles that I need to convert some colors on and save as Illustrator files.  I have created a swatch group with the colors I need and placed it in the Swatches panel so that it appears when I use the recolor feature in CS4.  The issue is that the swatch group disappears from the Swatches panel when I open the next file.  I want to know how I can add a swatch group to the Swatches panel so that every file that is opened has this swatch group present.
    Adrian.

  • Project Server 2010 Resource Assigments - Need a license for every Resource?

    I am trying to determine the requirements for Project Server 2010 licenses.
    In Project Server 2010, I need to add resources to the pool, then assign a resource to a project task.  The task will be maintained/statused through a manager, not the resource.  
    Does that resource need to have a Project Server license even if the resource never accesses Project Server even through PWA?

    Hi JenKranich,
    You need licences only for users that will access
    Project Server data by any means :
    MS Project Pro, Sharepoint sites and/or
    PWA.
    But resources not associated with users are not "real person" accessing data but just informal entity, thus no need for licences for those resources.
    It is important to note that if those resources can access the SharePoint site, since it contains Project Server data (risks, issues, deliverables), then they DO need a licence.
    Hope this helps.
    Guillaume Rouyre - MBA, MCP, MCTS

  • Simple MDX : Associated Date Value for returned week number on Row Axis ?

    Team , I have this MDX Below :
    I'm trying to see if i can also have a Column which  Uniques the week Starting/Ending Date   as below , Thanks in advance for your help and time .
    1 20040101  20040101  20040103    (null)
    1 20040102  20040101  20040103      1
    1 20040103  20040101  20040103     (null)
    2 20040104  20040104  20040110    (null)
    2 20040105  20040104  20040110       1
    2 20040106  20040104  20040110       1
    2 20040107  20040104  20040110     (null)
    2 20040108  20040104  20040110      (null)
    2 20040109  20040104  20040110      (null)
    2 20040110  20040104  20040110      (null)
    Rajkumar Yelugu

    Hi Rajkumar,
    According to your description, you want to show the week start and week end date together with the date dimension members, right? In this case, you can add week start and week end attribute to date dimension. Adding Week Start and Week End dates to your
    Date Dimension table can make navigating your dimensional model extremely handy and tasty to the end user. Please refer to the link below to see the detail information.
    Calculating Week Start and Week End Dates Dynamically
    Hope this helps.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Help needed: Data source for Facilities management (tables VTB_ASGN*)?

    Hi all,
    I am looking for a data source for facilities management in R/3 (PI 2004_1_470)
    The tables are concerning VTB_ASGN* etc.
    every feedback is highly appreciated and rewarded.
    Thanks and regards,
    Sally

    Hello Sally,
    Did you ever find a solution to this issue?
    My client is also looking to do reporting on facilities in BW and integrate this data into liquidity planning in SEM-BPS. However, it looks like this will have to be a custom extractor calling one of the two function modules either FTR_FC_GET_COMMITMENT or FTR_FC_GET_COMM_DRAW_FEE.
    Gregory

  • UPTO total need to display for every continue month

    Hi All,
    In one of my report I need two type of columns
    1. Month wise total - Coming correctly
    2. UPTO total- In this column I need to display total of all previous invoices upto month for that column displays for a particular Customer.
        Example :-
    Customer
    Sep-12
    Sep-11
    Aug-12
    Aug-11
    UPTO-Sep-12
    UPTO-Sep-11
    UPTO Aug-12
    ABC
    10
    12
    15
    13
    UPTO Aug 12 + Sep 12
    UP TO Aug11+sep11
    UP TO Jul-12+aug12
    As per above example I need a running sum but in horizontal way and as per customer and Month.
    Please suggest how I can achieve this.
    Thanks in advance
    Ashok K Gupta

    Hi,
    I tried all three function of Time Series but all three are not giving appropriate result.
    Thanks\
    Ashok

  • Need an expertise for a week gig in tokyo

    I know this might not be the forum
    but i am in need for a voip engineer for agig in tokyo one week interested
    contact me at [email protected]

    Roy,
    Sadly, ProgressBar in WD is suitable for displaying some 'static' percent value rather then for real-time visualization of process' progress. The problem is in fact that separate HTTP request/response round-trip required to update values of UI element (incl. ProgressBar) and there is no way in HTTP to push-back content to browser.
    Also you can do this but it is strictly unrecommended in J2EE application (due to use of multithreading):
    1. In first request/response cycle (some WD action) you set up Timer UI control and fork new thread that perform loading of data.
    2. In subsequent requests (as a result of Timer.onTimer action execution) you poll thread for progress via some variable shared between 2 threads and update progress bar accordingly
    3. If on next timer invocation the work is done, you are navigating to result or populate context to show result or whatever. DO NOT MODIFY WD CONTEXT OR INVOKE CONTROLLERS METHODS FROM SEPARATE THREAD!
    VS

  • Terms of Payment Due date as Tuesday Every Week.

    Dear Gurus,
    I was trying to figure out a term of payment by the following rule:
    If the invoice was posted on Nov 2009, the due date shall be
    From  Nov 2 to 8: Due date is Dec 22 (Tuesday) 47 days pasted.
    From Nov 9 to 15: Due date is Dec 29 (Tuesday)    47 days pasted.
    From Nov 16 to 22: Due date is Jan 5 2010 (Tuesday) 47 days pasted.
    The terms of payment in OBB8 are all configured by monthly base. Is there a way that I can do it by weekly base?
    Looking forward to your reply.
    Thank you very much.
    Emma

    Hi,
    You can create different payment terms for 7 Days,14 Days,21 Days like that and create one more payment term of Installment type and assign the above payment terms to that so that your due will be seperated into different line items with the above .
    thanks and regards,
    N.Kumar

  • WRT150N needs to be reset every week

    WRT150N V1.1 Firmware 1.01.9
    On average once per week all of the devices in the house can no longer connect to the WRT150N. Unplugging the WRT150N for 30 seconds and replugging it in invariably solves the problem.
    My WRT54 did this too, but I figured it would've been fixed by now.
    Is there a solution to this problem?
    Everytime I have to reset the WRT150N, I have to reset my NAS - everything seems to recover ok - but it is still a pain.
    Thanks,
    Bob

    I already have the latest firmware. Like the people on the thread below that goes on for 7 pages about the same problem, I have tried a lot of these standard solutions and none work for any great length of time.
    It also turns out it isn't once a week - my wife said she actually has to reset the modem almost every day when she goes to use the internet!
    I will probably just dump this thing. It sounds like the Airport Extreme is a popular choice.
    If there is a real solution I would like to hear it before I spend more dough.
    Thanks,
    Bob

  • System creates group for every share point

    Every time I create a new share point on my OS X Server 10.5, a group is created by the system on the fly along with it.
    For example, I created a folder nameded Research Office and shared in Server Admin. Then when I assign the permission for the share point in Server Admin, I see a group called Research Office group with a GID of 124. However, this group does not appear in Workgroup Manager so I can not assign members to it.
    Anyone see this before?

    These groups are 'local' (Not LDAP) I still have difficulty wrapping my head around some of the rules about the 'how' this works but assigning LDAP users to this group does work!
    OK _To see this group(s)_.
    1: Open Workgroup Manager.app.
    2: Select /Local/Default in your Authentication list (this spot is between the Toolbar and the 4 (or 5) icons for User, Groups, Computer Groups etc.) We are looking for the place that should say something like 'Authenticated as XXXXX to local directory /Local/Default')
    3: Select the Groups icon (3 Shadows standing together)
    4: Select Menu View, Show System Users and Groups
    5: Now you will be able to select these groups.
    _To add LDAP users and groups to this 'local' group._
    1: Highlight the group in question
    2: Select the Members tab in the right pane
    3:Click the plus
    4: After the tray slides out, at the top of the tray, you will see a disclosure arrow and Local Directory /Local/Default. Click on it and select /LDAP/127.0.0.1
    Now you can select your LDAP users to assign rights.
    Peter

  • Customized netweaver login screen needs seperate login for every mime

    Hi all,
    we are running ECC6 and have customzed our netweaver login screen (copied CL_ICF_SYSTEM_LOGIN to <ownClass>, redefined HTM_LOGIN, maintained it in SICF, etc.).
    And it works great - but:
    At the first call the system wants login/pw of each mime used on the login screen.
    But only for the first time.
    I can't repeat it.
    But it happens to every user.
    Correctly deleting cookies (close all screens; control->internet options-> delete cookies) CANNOT repeat the behaviour.
    Globally invalidating http server cache CANNOT repeat the behaviour.
    mimes on login screen are called like:
    https://<servername>:<https-port>/sap/bc/bsp/sap/public/bc/bsp/<applname>/xy.jpg
    So we need a login to see our login screen
    pls help...

    > All URLs under /sap/public run with user SAPSYS and so don't need any login.
    Bugger here is that the code which retrieves the object from the MIME repository makes an authorization check.
    CL_MIME_SERVICES method -> MIME_CHECK_AUTHORITY
    So it cannot run under SAPSYS as the user cannot be assigned any authority, let alone S_DEVELOP... (which in my opinion is much too strict here...). You will need to save a SERVICE user's logon credentials into the ICF service to make it visible to the user who has not logged in yet.
    Or... use SSO..
    Cheers,
    Julius

Maybe you are looking for

  • How do I use a FileStream with an IFilePromise without knowing the File?

    I've finished the implmentation of my project using Async IFilePromises by extending the ByteArray class. I can drag out of my application and files are created by copying bits over the network, etc. The issue I'm running into is that because I used

  • Release strategy reversal for the purchase requisition.

    Hi all, I have a scenario were we have three release levels to release the PR through ME54N tcode. After all the levels are released,If at the first level the PR release is cancelled all other levels are automatically cancelled. Now my concern is unt

  • How do I make preview show only one page at a time in full screen

    When I show a document using full screen (or slideshow) in Preview, it shows two pages at a time.  I just want to show one at a time, but can't find anything that lets me specify this.  There is no relevant Preference that I can see, and if I check s

  • Mail "disappears" after a period of inactivity

    Since upgrading to Leopard a strange problem is occurring. On returning to iMac after period of inactivity mail appears "open" in dock and menus appear at top of screen. However, the application just won't display anything at all. Only solution is to

  • Getting info out of an excel file like a database

    Hi, The problem i have is that i have to get info out of an excel file like a database. So i have to be able to perform a kind of query, but to an excel file. Is this possible? lay-out excel file: number | request | chemical composition | | C | Mn |