Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sushil
Starting Member
11 Posts |
Posted - 2010-05-19 : 19:25:31
|
| I need a logic which can transform the following records in a table A Years Price2000 552001 552002 602003 652004 702005 752006 752007 752008 802009 902010 100 toYears Price2000 552002 602003 652004 702005 752008 802009 902010 100It is basically not showing the reocords for next year if price is same. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-05-20 : 02:35:53
|
If price is never falling:select min(years) as years,pricefrom @testgroup by priceorder by years No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-05-20 : 03:34:55
|
if the Years is continuous,select t1.Years, t1.Pricefrom table1 t1 left join table1 t2 on t1.Years = t2.Years + 1where t1.Price <> t2.Priceor t2.Price is null KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|