Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2003
    Posts
    14

    Unanswered: Quaterly Data From Selected Range

    Hi all,

    I have one table with period data time and composite integer
    now i want to select the sum(composite) for quaterly like
    if user selects 200001 to 200303 i want all the quater which fall under the selection/
    in this we have q1.q2.q3.q4 of 2000 and
    q1.q2.q3.q4 of 2001 and q1.q2.q3.q4 of 2002 and q1 2003...i want all those quaters..each one row....
    so how to do that let me know the query ....

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    did you try this ?

    rudy

  3. #3
    Join Date
    Mar 2003
    Location
    Bucharest, Romania
    Posts
    80
    Like R937 said (with one corection of mine), try this:

    select year(period) as year,cast( (month(period)+2) / 3 as integer ) as quarter, sum(composite)
    from cdh_price_gap
    group by year(period),cast( (month(period)+2) / 3 as integer )

    or

    select year(period) as year,cast( ((month(period)-0.3)/ 3)+1 as integer ) as quarter, sum(composite)
    from cdh_price_gap
    group by year(period),cast( ((month(period)-0.3)/ 3)+1 as integer )


    IONUT CALIN


    PS
    From what I understant you need you need separate sums for q1 2002 and q2 2003 (in this case you alo have to group by year of date field)

    Good Luck!
    Last edited by ionut calin; 04-14-03 at 03:01.

Posting Permissions

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