Getting Previous Date of and attribute (NO_ofCards_Ordered)

  • select convert(varchar(10),Captured_Date,23) as Captured_Date,

    sum(Number_Cards_Ordered) as Number_Cards_Ordered,

    sum(Number_Cards_Produced) as Number_Cards_Produced,

    (select Number_Cards_Ordered from Card_Operations_Data

    where convert(varchar(11),Captured_Date) = convert(varchar(11),dateadd(dd,-1,Captured_Date))) as Previous_Day_CardsOrdered

    from Card_Operations_Data

    where Number_Cards_Ordered is not null

    group by convert(varchar(10),Captured_Date,23)

  • Could you please provide a few rows of sample data, and what you would expect the output to look like based on that sample data?

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Captured_DateNumber_Cards_OrderedNumber_Cards_ProducedPrevious_day # of Cards_Ordered

    2008/12/03118530 111094 0

    2009/01/22103147 99315 0

    2009/07/0110836 9797 0

    2009/07/024086 4925 10836

    2009/07/034086 4925 4086

    2009/07/066283 7662 4086 Weekend

    2009/07/0710633 6283 6283

    2009/07/084795 10633 10633

    2009/07/092805 4773 4795

    2009/07/104249 2805 2805

    2009/07/1314583 4249 4249 Weekend

    2009/07/148248 14583 14583

    2009/07/154470 8205 8248

    2009/07/163635 4470 4470

    2009/07/173743 3635 3635

    2009/07/203623 3743 3743 Weekend

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

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