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 |
gfaryd
Starting Member
27 Posts |
Posted - 2012-06-15 : 05:21:30
|
dear all update dset group_no = (select count(distinct x.rec_1) from tbl_data x where x.rec_1 <= d.rec_1)from tbl_data dwhere result = 'Y'can some one explain (x.rec_1 <= d.rec_1) condition in the above query |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-15 : 05:27:09
|
It counts the number of rec_1 values in the table less than the current one. It will give a rank for the current row.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-17 : 12:09:14
|
if 2005 or above you can use window function DENSE_RANK() for that------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|