SQL Query question (count dates for each month)
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 1 of 1

Thread: SQL Query question (count dates for each month)

  1. #1
    Join Date
    Aug 2011
    Posts
    1

    SQL Query question (count dates for each month)

    Hi there,

    Hope you can help me with the following, i have the following view availble:
    DD/MM/YYYY


    ENTITY | StartDate | EndDate | CodeA | CodeB | Revenue | Currency
    AZERT | 01/01/2011 | 02/01/2011 | SU | BOLD | 100 | EUR
    AZERT | 28/01/2011 | 02/02/2011 | SU | BOLD | 500 | EUR

    Can someone help with a query to pull the data so that I get the following summed?

    ENTITY | YYYY.MM | CodeA | CodeB | DAYS | TIMES | Revenue | Currency
    AZERT | 2011.01 | SU | BOD | 5 | 2 | 500 | EUR
    AZERT | 2011.02 | SU | BOD | 1 | 0 | 100 | EUR


    Where YYYY.MM is created depending on the difference between Sdate and EDate.
    And DAYS is the variance between the start and end day in the right month
    And TIMES is the number of times that the StartDate occurs in that month
    Revenue splitted depening how many days there are.
    Last edited by JohnSQL; 08-18-2011 at 06:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width