December 28, 2010 at 7:01 am
I am using SS2K8 SSMS,
Fld1Fld2Fld3
A1/15/201015
A2/16/2010
A4/17/201035
A5/15/201065
A6/16/201010
A8/17/2010
A10/15/201068
A12/16/201045
B3/16/201052
B9/16/201063
B11/16/201045
Fld1Fld23Months6Months9Months12Months
A1/15/201054302010
B3/16/20104503215
For every Fld1, it needs to take minimum date of fld2. From the count of minimum date in fld2,
I need first 3 Months avg, first 6months avg like wise….like shown in 2nd table.
Please help me in this. How to write t-sql
Thanks in Advance.
December 28, 2010 at 3:24 pm
Maybe with some table definitions, scripts to generate test data and clear rules about what you are looking for you might get some help. Given the unclear tables, lack of test data and unclear results nobody has anything to go on.
_______________________________________________________________
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/
December 28, 2010 at 8:43 pm
maheshcrazy.it (12/28/2010)
I am using SS2K8 SSMS,Fld1Fld2Fld3
A1/15/201015
A2/16/2010
A4/17/201035
A5/15/201065
A6/16/201010
A8/17/2010
A10/15/201068
A12/16/201045
B3/16/201052
B9/16/201063
B11/16/201045
Fld1Fld23Months6Months9Months12Months
A1/15/201054302010
B3/16/20104503215
For every Fld1, it needs to take minimum date of fld2. From the count of minimum date in fld2,
I need first 3 Months avg, first 6months avg like wise….like shown in 2nd table.
Please help me in this. How to write t-sql
Thanks in Advance.
Welcome aboard. To explain what Sean is talking about, take a look at the first link in my signature lines at the bottom of this post.
Also, take a look at the following article for how to do dynamic cross-tabs... which is just exactly what you need...
http://www.sqlservercentral.com/articles/Crosstab/65048/
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply