February 1, 2013 at 3:53 am
Hi guys,
I have table with sample data below.
I want to retrieve the record for the fiscal year FY-12 i.e Between 01-10-2012 to 30-09-2013..One year data
WorkId ChildName PlanStartDate PlanEndDate
158 Improve trucks NULL 2012-12-21
158 Define NULL 2011-12-31
158 Measure 2011-12-31 2012-01-07
158 Analyze 2012-01-07 2012-02-11
158 Improve 2012-02-11 2012-09-29
I want the result to be like below
WorkId ChildName Oct Nov Dec Jan feb March.........Sep
158 Improve trucks NULL NULL Define Measure Analyze Analyze Analyze
Comparing with plan start and end date i need to pivot the data for fiscal year...
February 1, 2013 at 9:03 am
With no more details than that I will suggest you to look at the article in my signature about cross tabs. It will explain how to accomplish this.
If you need help with the code you should read the article in my signature about best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
February 1, 2013 at 6:48 pm
farooq.hbs (2/1/2013)
Hi guys,I have table with sample data below.
I want to retrieve the record for the fiscal year FY-12 i.e Between 01-10-2012 to 30-09-2013..One year data
WorkId ChildName PlanStartDate PlanEndDate
158 Improve trucks NULL 2012-12-21
158 Define NULL 2011-12-31
158 Measure 2011-12-31 2012-01-07
158 Analyze 2012-01-07 2012-02-11
158 Improve 2012-02-11 2012-09-29
I want the result to be like below
WorkId ChildName Oct Nov Dec Jan feb March.........Sep
158 Improve trucks NULL NULL Define Measure Analyze Analyze Analyze
Comparing with plan start and end date i need to pivot the data for fiscal year...
So what happened to "Improve"???
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply