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 |
mani_1234
Starting Member
24 Posts |
Posted - 2012-09-30 : 23:44:33
|
i have input table like this a b sq_no a1 b1 1 b1 a1 2 a2 b2 3 c2 d2 4c1 d1 5 d1 c1 6 i want output like this which have unique combination only with desc. order wrt to sq_no a b sq_no d1 c1 6 c2 d2 4 a2 b2 3 b1 a1 2 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-10-01 : 00:18:13
|
[code]select *from( select *, rn = row_number() over ( partition by case when a < b then a + b else b + a end order by sq_no desc) from input) dwhere d.rn = 1order by sq_no desc[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
mani_1234
Starting Member
24 Posts |
Posted - 2012-10-01 : 01:03:09
|
thnx bt it can b more optimized if possble in terms of io and time |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-01 : 10:56:13
|
quote: Originally posted by mani_1234 thnx bt it can b more optimized if possble in terms of io and time
do you mean current its taking lots of io?can you check execution plan and see what are costly steps?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|