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 200203 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 20003...i want all those quaters..each one row....

    so how to do that let me know the query ....

  • DECLARE @d1 AS char(6)

    DECLARE @d2 as char(6)

    SET @d1 = '200001'

    SET @d2 = '200203'

    SELECT YEAR(period) AS 'Year',DATEPART(quarter,period) as 'Quarter',

    SUM(composite) AS Composite_Total

    FROM tablea

    WHERE CONVERT(CHAR(6),period,112) between @d1 and @d2

    GROUP BY YEAR(period),DATEPART(quarter,period)

    ORDER BY YEAR(period),DATEPART(quarter,period)

    Edited by - davidburrows on 04/14/2003 02:13:21 AM

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply