Data Comparison

  • Good Morning,

    I have sales table with following fields:

    Yr, Qtr, Sales

    How do I compare current year quarter sales with the same quarter last year?

    Original table:

    YrQtrSales

    20091$$

    20092$$

    20093$$

    20094$$

    20101$$

    Result that I want: Ex – running report for year 2010 and qtr 1

    YrQtrSalesDifference

    20101$$(2009 Qtr 1 $$) – (2010 Qtr 1 $$)

  • Something like :

    SELECT

    a.Yr, a.Qtr, a.Sales, (a.Sales - b.Sales) AS [Difference]

    FROM sales a

    INNER JOIN sales b

    ON (b.Yr + 1) = a.Yr

    AND b.Qtr = a.Qtr

    WHERE a.Yr = 2010

    Converting oxygen into carbon dioxide, since 1955.
  • Thanks for the reply.

    This query give result as:

    Yr, Qtr, Sales, Difference

    2009,4, $$, $$

    I would like to see:

    Y09Q4 Sales, Y08Q4Sales, Difference

  • Golly!

    SELECT

    a.Sales[Y09Q4 Sales]

    , b.Sales[Y08Q4 Sales]

    , (a.Sales - b.Sales) AS [Difference]

    FROM sales a

    INNER JOIN sales b

    ON (b.Yr + 1) = a.Yr

    AND b.Qtr = a.Qtr

    WHERE a.Yr = 2009

    AND a.Qtr = 4

    Converting oxygen into carbon dioxide, since 1955.

Viewing 4 posts - 1 through 3 (of 3 total)

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