Looping through date column - Summing hours per day

All,
Running the query below against my timesheet tables I get the following results:
-----SQL CODE------
SELECT
ts.ts_date Date,
ts.user_name Name,
tc.account Account,
ts.no_of_hrs Hours,
SUM(ts.no_of_hrs) OVER(PARTITION BY ts.ts_date) Daily_Total
FROM
eba_time_timesheet ts,
eba_time_timecodes tc
WHERE
ts.timecode_id = tc.id AND
ts.user_name LIKE 'JohnD'
ORDER BY
1
-----RESULTS-------
Date          Name          Account     Hours     Daily Total
1-Dec-09     JOHND          489310          1.5     8
1-Dec-09     JOHND          486830          1.5     8
1-Dec-09     JOHND          481710          3     8
1-Dec-09     JOHND          481210          0.5     8
1-Dec-09     JOHND          486840          0.5     8
1-Dec-09     JOHND          485710          0.5     8
1-Dec-09     JOHND          481010          0.5     8
2-Dec-09     JOHND          481710          1     8
2-Dec-09     JOHND          485710          7     8
3-Dec-09     JOHND          481710          6     8
3-Dec-09     JOHND          488810          1.5     8
3-Dec-09     JOHND          481310          0.5     8
4-Dec-09     JOHND          489710          8     8
7-Dec-09     JOHND          481110          0.5     8
7-Dec-09     JOHND          489710          7     8
7-Dec-09     JOHND          481210          0.5     8
However, I would prefer the Daily Total column be a row in the results instead of a column. Here is an example of how I would prefer the results. This statement will then be sent to a calendar for each user to see there time for each account and total time per day.
Date          Name          Account     Hours
1-Dec-09     JOHND          489310          1.5     
1-Dec-09     JOHND          486830          1.5     
1-Dec-09     JOHND          481710          3     
1-Dec-09     JOHND          481210          0.5     
1-Dec-09     JOHND          486840          0.5     
1-Dec-09     JOHND          485710          0.5     
1-Dec-09     JOHND          481010          0.5     
*1-Dec-09     JOHND          Daily Total     8*
2-Dec-09     JOHND          481710          1     
2-Dec-09     JOHND          485710          7
*2-Dec-09     JOHND          Daily Total     8*
3-Dec-09     JOHND          481710          6     
3-Dec-09     JOHND          488810          1.5     
3-Dec-09     JOHND          481310          0.5
*3-Dec-09     JOHND          Daily Total     8*
4-Dec-09     JOHND          489710          8
*4-Dec-09     JOHND          Daily Total     8*
7-Dec-09     JOHND          481110          0.5     
7-Dec-09     JOHND          489710          7     
7-Dec-09     JOHND          481210          0.5
*7-Dec-09     JOHND          Daily Total     8*
Any help would be greatly appreciated.
This is my 1st post so if I've left something out or you need additional info please let me know.
I’m using Oracle 10g

user9160575 wrote:
Thanks for all the input! I ended up using the GROUP BY ROLLUP and adding a CASE statement for inserting "DAILY TOTAL" in the account column.If you are on at least 10g, model solution could be simpler:
with t as (
           select to_date('1-Dec-09','dd-mon-yy') dt,'JOHND' name,489310 account,1.5 hours,8 daily_total from dual union all
           select to_date('1-Dec-09','dd-mon-yy'),'JOHND',486830,1.5,8 from dual union all
           select to_date('1-Dec-09','dd-mon-yy'),'JOHND',481710,3,8 from dual union all
           select to_date('1-Dec-09','dd-mon-yy'),'JOHND',481210,0.5,8 from dual union all
           select to_date('1-Dec-09','dd-mon-yy'),'JOHND',486840,0.5,8 from dual union all
           select to_date('1-Dec-09','dd-mon-yy'),'JOHND',485710,0.5,8 from dual union all
           select to_date('1-Dec-09','dd-mon-yy'),'JOHND',481010,0.5,8 from dual union all
           select to_date('2-Dec-09','dd-mon-yy'),'JOHND',481710,1,8 from dual union all
           select to_date('2-Dec-09','dd-mon-yy'),'JOHND',485710,7,8 from dual union all
           select to_date('3-Dec-09','dd-mon-yy'),'JOHND',481710,6,8 from dual union all
           select to_date('3-Dec-09','dd-mon-yy'),'JOHND',488810,1.5,8 from dual union all
           select to_date('3-Dec-09','dd-mon-yy'),'JOHND',481310,0.5,8 from dual union all
           select to_date('4-Dec-09','dd-mon-yy'),'JOHND',489710,8,8 from dual union all
           select to_date('7-Dec-09','dd-mon-yy'),'JOHND',481110,0.5,8 from dual union all
           select to_date('7-Dec-09','dd-mon-yy'),'JOHND',489710,7,8 from dual union all
           select to_date('7-Dec-09','dd-mon-yy'),'JOHND',481210,0.5,8 from dual
select  dt "Date",
        name "Name",
        account "Account",
        hours "Hours"
  from  t
  model
    dimension by(dt,name,to_char(account) account)
    measures(hours,daily_total,0 seq)
    rules upsert all(
                     hours[any,any,'Daily Total'] = max(daily_total)[cv(dt),cv(name),any],
                     seq[any,any,'Daily Total'] = 1
  order by dt,
           name,
           seq,
           account
Date      Name  Account                                       Hours
01-DEC-09 JOHND 481010                                           .5
01-DEC-09 JOHND 481210                                           .5
01-DEC-09 JOHND 481710                                            3
01-DEC-09 JOHND 485710                                           .5
01-DEC-09 JOHND 486830                                          1.5
01-DEC-09 JOHND 486840                                           .5
01-DEC-09 JOHND 489310                                          1.5
01-DEC-09 JOHND Daily Total                                       8
02-DEC-09 JOHND 481710                                            1
02-DEC-09 JOHND 485710                                            7
02-DEC-09 JOHND Daily Total                                       8
Date      Name  Account                                       Hours
03-DEC-09 JOHND 481310                                           .5
03-DEC-09 JOHND 481710                                            6
03-DEC-09 JOHND 488810                                          1.5
03-DEC-09 JOHND Daily Total                                       8
04-DEC-09 JOHND 489710                                            8
04-DEC-09 JOHND Daily Total                                       8
07-DEC-09 JOHND 481110                                           .5
07-DEC-09 JOHND 481210                                           .5
07-DEC-09 JOHND 489710                                            7
07-DEC-09 JOHND Daily Total                                       8
21 rows selected.
SQL> SY.

Similar Messages

  • How do I go about this? Creating table while looping through dates?

    How do I do this? Creating table while looping through dates?
    I have a table with information like:
    ID---Date---Status
    1-------04/23-----Open
    1-------04/25-----Open
    2-------04/24-----Closed
    3-------04/26-----Closed
    What I want to do is create another table based on this per ID, but have all the dates/statuses on the same line as that ID number (as additional columns). The problem is that the number of columns needed is to be dynamically decided by the number of dates.
    To illustrate my example, I'm looking to achieve the following:
    ID---04/23 Status---04/24--Status---04/25--Status---04/26--Status
    1----Open--------------<null>-------------Open---------------<null>
    2----<null>------------Closed-------------<null>-------------<null>
    3----<null>------------<null>-------------<null>-------------Closed
    What would be the best way to go about this?
    Can someone please point me in the right direction?
    Would I need to do some looping?
    Thanks in advance!

    thedunnyman wrote:
    How do I do this? Creating table while looping through dates?
    I have a table with information like:
    ID---Date---Status
    1-------04/23-----Open
    1-------04/25-----Open
    2-------04/24-----Closed
    3-------04/26-----Closed
    What I want to do is create another table based on this per ID, but have all the dates/statuses on the same line as that ID number (as additional columns). The problem is that the number of columns needed is to be dynamically decided by the number of dates.
    To illustrate my example, I'm looking to achieve the following:
    ID---04/23 Status---04/24--Status---04/25--Status---04/26--Status
    1----Open--------------<null>-------------Open---------------<null>
    2----<null>------------Closed-------------<null>-------------<null>
    3----<null>------------<null>-------------<null>-------------Closed
    What would be the best way to go about this?
    Can someone please point me in the right direction?
    Would I need to do some looping?
    Thanks in advance!I hope you are asking about writing a query to DISPLAY the data that way ... not to actually create such a massively denormalized table ....

  • Does anyone know if it is possible to change the display in week view to show 24 hours per day for those of us that work irregular hours

    Does anyone know if it is possible to change the display in week view to show all 24 hours per day for those of us that work irregular hours.
    Also is it possible to have all of the 'all day' entries showing, not just 3.5 of them.
    The app Week Cal HD was the perfect calendar until Apple removed it so could they please offer the same facilities that it offered.

    Does anyone know if it is possible to change the display in week view to show all 24 hours per day for those of us that work irregular hours.
    Also is it possible to have all of the 'all day' entries showing, not just 3.5 of them.
    The app Week Cal HD was the perfect calendar until Apple removed it so could they please offer the same facilities that it offered.

  • PWA Timesheet - How to limit hours per day on timesheet submission?

    I've set "Maximum Hours per day" limiation to 24 hours on "Timesheet settings and defaults" and it works when a user click "Save" on "Timesheet" view. 
    But when the user click "Send" without saving first, it bypasses this limitation and save the timesheet reporting with any amount of hours that the user entered.
    Is there any way to solve this and limit the user so he won't be able to submit more than 24 hours per day?
    Thanks

    Under configure timesheet settings and defaults
    In the Hourly Reporting Limits section, specify the maximum and minimum hours allowed in a timesheet and the maximum number of hours allowed to be reported in a day. If team members report time beyond these limits, errors appear on their timesheets when
    they submit them.
    make it 8 hours then check.
    kirtesh

  • Fair Usage Policy - 6 hours per day exceeded

    Hi,
    My Fair Usage Policy - 6 hours per day is about cross the limit. Is there any ways to reset it before GMT 0000hrs
    rgds

    Unfortunately no
    Otherwise if everyone could reset it on their own then there is no point for the restriction.
    Andre
    If answer was helpful please mark it with Kudos and if issue is resolved mark it with solution. This will help other users find this answer more easily. Thanks in advance!

  • Row 1 Error - Please set the Full Time Equivalent Hours Per Day implementat

    Hi all
    While defining the Enable Workplan Structure in oracle projects i am getting the below error
    Row 1 Error - Please set the Full Time Equivalent Hours Per Day implementation option before enabling the Workplan Structure.
    Plesase can you share and doc or guide where can i set this implementation option
    Thanks in advance

    Hi
    Navigate to Projects> Setup > System > Implementation Options
    There is a tab named - Staffing
    On that form you should enter the Full Time Equivalent Hours - Per Day and Per Week.
    Dina

  • ASA5510 - Is it possible to give users access 2 hours per day?

    Hi!
    As the topic say; is it possible to set up so specific users only have, say, 2 hours of internet access per day?
    They should be able to log on any time of the day, and so many times they want, as long as the total usage does not exeed 2 hours per day.
    Is this possible on a ASA5510, or any other device Cisco is selling?
    Thanks.

    You would have to do that with a proxy or web security appliance. Take a look at Cisco's Ironport products.
    http://www.cisco.com/en/US/products/ps10164/index.html

  • Enterprise Global - working time v hours per day

    Hi, can someone remind me whether I can set Hours per day and default start/finish times within the enterprise global template or is that a configuration that must be made inidividually by each user with project professional installed?
    Thanks
    Steve

    Hi Steve,
    It has to be set for each user with Project Pro installed.
    That being said, you can configure GPO (Group Policy Management) to set automatically those options for all users.
    Here are some references:
    https://technet.microsoft.com/en-us/windowsserver/bb310732.aspx
    https://technet.microsoft.com/en-us/library/cc740076(v=ws.10).aspx
    https://msdn.microsoft.com/en-us/library/bb742376.aspx
    https://technet.microsoft.com/en-us/library/cc753298.aspx
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • How to loop through dates using For Loop?

    Hi All,
    I assume the For Loop is the best way to loop through days in a date range, but I can't figure out how to add a day in the "AssignExpression" box.  The following gets the errors "The expression contains unrecognized token 'DAY'",
    and "Attempt to parse the expression 'DATEADD(DAY, 1, @CounterPlayer)' failed and returned error code 0xC00470A4."
    InitExpression: @CounterPlayer = @DownloadFileDatePlayer
    EvalExpression: @CounterPlayer <= @Today
    AssignExpression: @CounterPlayer = DATEADD(DAY, 1, @CounterPlayer)
    I need to step through days, not through files.  What am I doing wrong here?  I changed "DAY" to "Day," but that didn't fix it.
    Thanks,
    Eric

    DOH!  It just needed properly placed quotes.  Here's the answer:
    AssignExpression: @CounterPlayer = DATEADD("DAY", 1, @CounterPlayer)

  • How to loop through data of ALV grid in Webdynpro for Abap view

    hello,
    I have a view with an ALV component(SALV_WD_TABLE). I just want to loop through the lines shown (particularly when the user has set filter).
    Can you help me to find how to reach the internal table ?
    In summary, I want to know the reverse method of BIND_TABLE()
    Thanks!

    Not really...
    Here is the solution :
      DATA lo_ui TYPE  if_salv_wd_table=>s_type_param_get_ui_info.
      lo_ui = lo_interfacecontroller->get_ui_info( ).
      DATA: lt_displayed     TYPE salv_bs_t_int,
            li_displayed     TYPE int4.
      lt_displayed = lo_ui-t_displayed_elements.
      check not lt_displayed is initial.
      loop at lt_displayed into li_displayed.
    Regards

  • Loop Through Date Range

    Hi guys,
    I have date range as parameter like 01/JAN/2009 TO 16/JAN/2009 now i want to loop through this date range and want to get date like
    01/JAN/2009,02/JAN/2009.....16/JAN/2009.how can i achive this ?
    Thanks
    Ron

    Hi,
    What do you mean by loop through?
    SQL> with dates as (select to_date('01/JAN/2009', 'dd/mm/yyyy') start_date
                         ,to_date('16/JAN/2009', 'dd/mm/yyyy') end_date from dual)
    select start_date + level - 1 from dates connect by level <= end_date - start_date + 1
    START_DATE
    01/01/2009
    02/01/2009
    03/01/2009
    04/01/2009
    05/01/2009
    06/01/2009
    07/01/2009
    08/01/2009
    09/01/2009
    10/01/2009
    11/01/2009
    12/01/2009
    13/01/2009
    14/01/2009
    15/01/2009
    16/01/2009
    16 rows selected.Regards
    Peter

  • Possible to show fewer Calendar hours per day?

    Is there a way to reduce the number of hours Calendar shows each day? 
    My appointments happen between the hours of 8am and 8pm.  But CAL shows all 24 hours each day.  If I have one appointment at 8am, one at 2pm, a third at 4pm and maybe a dinner at 7pm, the page view on iPhone limits my view to one or two of these appointments.  To see others I have to scroll up or down.  Not a big deal but I'd like to see all that day's appointments on one page view.
    Is there a way to do this?

    See Apple's article titled "Controlling when a user can access your network" found at:
    http://docs.info.apple.com/article.html?path=Airport/5.0/en/ap2122.html

  • Land phone dial tone lost for 8 hours per day at same time

    For 2 weeks now, I lose my dial tone approximately 9:30 to 10:30 a.m. every day and intermet and then dial tone comes back on approximately 5:15 p.m. every day.  Verizon came out and checked outside box and said it is not their problem, the box is working fine, must be something with my wiring.  The same thing happened 2 years ago and Verizon fixed something on telephone wires down the block and everything was fixed.  How can it be problem with inside wiring if I only lose dial tone for approximately 8 hours every day.  Seems like it is something with maybe a switching station, something that they switch every day (maybe high volume time period), but my phone gets left behind.  One Verizon guy on the phone said he could see it was a problem with their network and it was fixed for one day.  Since then when I have called back, they keep telling me Verizon has to come into my home as there is a problem with inside wiring and cannot give me time period other than either 8 a.m. to 12 noon or 1 p.m. to 5 p.m. for them to show up.  Anyone have a problem like this?

    Your issue has been escalated to a Verizon agent. Before the agent can begin assisting you, they will need to collect further information from you.
    Please go to your profile page for the forum, and look in the middle, right at the top where you will find an area titled "My Support Cases". You can reach your profile page by clicking on your name beside your post, or at the top left of this page underneath the title of the board.
    Under “My Support Cases” you will find a link to the private board where you and the agent may exchange information. This should be checked on a frequent basis as the agent may be waiting for information from you before they can proceed with any actions.
    To ensure you know when they have responded to you, at the top of your support case there is a drop down menu for support case options. Open that and choose "subscribe".
    Please keep all correspondence regarding your issue in the private support portal.

  • Hours per day, iMac Help solution doesn't work

    My weekly view in iCal shows 24 hour days. I need only 8 am to 10 pm, 14 hr days. I went to iCal>Prefs>general and changed it to those hours and to show only 14 hour days. This affected NO change in iCal though iCal Help says;
    "To change the days of the week or the number of hours that appear in the main calendar view, choose iCal > Preferences, and make your choices from the Week and Day pop-up menus in the General pane. For example, you can choose to only see the hours from 9AM to 5PM on Monday through Friday."
    iCal>Preferences>general pane does not offer me week and day pop up menus as the help item suggests.
    I'm trying to switch from Now Up-To-Date to iCal. Surely apple hasn't released a calendar program that can't be adjusted as desired. (I found one thread on these discussion forums but it was 34 pages long: I found no solution in the first 3 pages and figured i'd post here, as it doesn't seem reasonable to have to read 34 pages x 15 posts/page to get an answer to such a simple question.
    I hope someone will be nice enough to point out the solution i'm overlooking.
    thanks

    Hi Dan,
    Thanks. I agree that provides a hack of sorts to achieve my goal. But can we also agree that it's a workaround unworthy of apple (or anyone's) quality software? I mean, a calendar program that by default shows all 24 hours and CAN'T have that changed, only the portion of it that shows at first?
    And if this is the only solution, what, then, is the usefulness of the preference i've changed to read: "Show 14 hours at a time" ?
    thanks
    terry

  • Fascinate will not connect with email server 3-5 hours per day.

    All the features on the phone; text messaging, internet browsing and the phone(coming and going) work well and quickly but my email problem is driving me nuts.
    I live in Williamsburg VA and have been back to the main store several times without luck. I've been on the phone with the 800# techs at Verizon, and while they try to help, still have the problem. They have reset the phone, manually walked me through the reset process--  similar to the automatically mode by dialing *228, #1.
    Regardless if I'm on the 3G network or WiFi(both showing 3 bars) I receive no email several time a day for up to 5 hours - -this is even though my home computer is getting them. I run a small business and the lost message are killing me.
    I'm open for any suggestions

    I'm having the same issue -check the laptop or PC and the inbox is filled with new emails, yet no new emails on the Fascinate......sometimes no new messages for 12-15hrs.  Tried soft reboots, deleting the email accounts and re-installing, updating roaming and still no timely emails incoming.  Spent 1hr 47min with Verizon and Samsung tech support for this very problem.  Bottom line per Samsung tech support -Droid Operating Platform (OS) is designed to run Gmail in 'real time' and any other ISP can take up to 2 days to hit your inbox.  Droid considers this perfectly acceptable.  Samsung tech support said to Google (not on your phone) 'droid apps' and then research apps for email.  He said to look only at those with a 5 star rating and with 100 ratings or more.  When asked if he could save me the time and hassle of researching and just tell me a good app, he couldn't - he could lose his job.  He was sympathetic and agreed it was **bleep**.
     Another tip he gave was to delete your email accounts BEFORE downloading an email app.  Once the app is downloaded re-install your email account(s).  Doing it otherwise will confuse the OS and you'll have the same lag time issues of incoming email.
    I'm going to try K 9 app based on research reviews.

Maybe you are looking for

  • Inefficient Creative Cloud

    I understand that one of the main goals of making Creative Cloud was to make the product easier to purchase and probably to reduce piracy, however here is a run-through of what is required of me as an end user to use Adobe's Creative Cloud. Visit ado

  • Is it possible to reduce/edit the size of the imported video file?

    Hello, I noticed the other day that I am nearing half full on my terabyte hard drive. In reflecting on what is on that drive, it occurred to me that there's a lot of footage that was ultimately never used. I was wondering whether there is a way to re

  • Find and replace in rtf file

    hello I would like to replace a bookmarks that are already created in a rtf template file I Know how to read the rtf file ,It is just that i can't figure out how to rplace a word inside this file here is my code File docFile = new File("C:\\test.rtf"

  • I changed my Apple ID but my iCloud won't change with it ...

    I changed my Apple ID a while ago because the email address it's synced with will expire in a few months. I got an iPhone 5 today (I previously had a 3GS) and although it's synced my contacts and music perfectly, my apps all say they're installing bu

  • Include attachments in a xml file without using mail adapter

    Hello Experts, Is there a way to include attachments like pdf or excel in a xml file? It is a file to file scenario in which i have to include the attachment in the output file. Thanks and regards, Merrilly