#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    3
    Rep Power
    0

    Exclamation Select Multiple Date Ranges


    Hello All,

    I have data such as 'hours', 'date' when and employee worked on the project. What I need is to select the total amount of hours per month of March, April, May, etc...

    I know how to select data per single date but wonder how to do it per multiple dates. How does one select total amount of hours per multiple date ranges (March, April...)?


    I appreciate your responses.

    Lubica
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    857
    Rep Power
    388

    Wink


    Did you try adding the hours by month?
    Something like this:
    Code:
      SELECT emp_no,
             TO_CHAR (date_worked, 'Month') "Month",
             SUM (hours_worked) Hours_Worked
        FROM My_project_tab
    GROUP BY emp_no, TO_CHAR (date_worked, 'Month')
    ORDER BY 1, 2;

    Comments on this post

    • debasisdas agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    3
    Rep Power
    0

    Thumbs down


    Hi,

    Thanks so much for reply. My issue is not so much to convert date to month.
    Here is my data:

    POST DATE EMPLOYEE HOURS_WORKED
    15-March-2011 Schmidt 7
    18-March-2011 Schmidt 2
    22-March-2011 Brown 5
    12-April-2011 Brown 18
    17-April-2011 Patterson 22
    7-May-2011 Schmidt 5
    9-May-2011 Brown 25

    I used statement such as:

    select employee, sum(hours_worked) from my_table
    where POST_DATE>='1-March-11' AND POST_DATE <= '31-MAR-11'
    group by employee
    order by employee;

    But don't know how to implement in one select statement a querry that will give me sum of hours_worked per employee for post_date = March, then for April, May....etc.
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    857
    Rep Power
    388

    Question


    Did you try the query I posted?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    3
    Rep Power
    0

    Red face




    Ahhh worked!!! Perfect. Thank you!

IMN logo majestic logo threadwatch logo seochat tools logo