Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Help with TSQL, getting StartDate and EndDate from WeekDate !!!


Help with TSQL, getting StartDate and EndDate from WeekDate !!!

Author
Message
Matt Miller (#4)
Matt Miller (#4)
SSCertifiable
SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)

Group: General Forum Members
Points: 7636 Visits: 18043
well - unless I'm completely off of the boat - OP is looking to do some fancy aggregation. He's trying to get a summary of the promo's on a given item, based on continuous weeks of promos. doing this based on recording sale prices of given items by outlets each week.



So - these three records



WeekDate, OutletId, ProductId, Price, cost, PromotionType, AdType, DisplayType, [X Value], [Y Value]

2006-10-21, 00370, a, b, c, d, e, f, g h

2006-10-28, 00370, a, b, c, d, e, f, g, h

2006-11-04, 00370, a, b, c, d, e, f, g, h

2006-11-11, 00370, a, b, c, d, e, f, g, h

2006-11-18, 00370, a, b, c, d, e, f, g, h

2006-11-25, 00370, a, b, c, d, e, f, g, h



Summarizes to one record

Start, end, ProductId, Price, cost, PromotionType, AdType, DisplayType, [X Value], [Y Value]

2006-10-21,2006-11-25, 00370, a, b, c, d, e, f, g h



whereas this

WeekDate, OutletId, ProductId, Price, cost, PromotionType, AdType, DisplayType, [X Value], [Y Value]

2006-10-21, 00370, a, b, c, d, e, f, g h

2006-10-28, 00370, a, b, c, d, e, f, g, h

2006-11-04, 00370, a, b, c, d, e, f, g, h

--notice the missing weeks in the here - more than 7 days between records

2006-11-18, 00370, a, b, c, d, e, f, g, h

2006-11-25, 00370, a, b, c, d, e, f, g, h



Summarizes to 2 records

Start, end, ProductId, Price, cost, PromotionType, AdType, DisplayType, [X Value], [Y Value]

2006-10-21,2006-11-04, 00370, a, b, c, d, e, f, g h

2006-11-18,2006-11-25, 00370, a, b, c, d, e, f, g h



A break in the weeks sequence (by productid+outletID), or a change in ANY of the other data elements would engender another record.



Zee - is that right?

----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search