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 |
|
Tien
Starting Member
12 Posts |
Posted - 2005-01-18 : 05:35:42
|
| Hi,I have SELECT with GROUP BY clause, also I added a calculated column named"ROWNUMBER" with value is "number of this row in result return by SELECT",how can I set value for this column? and it should reset for each rowsetgrouped by GROUP BY.Thanks,Tien, |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-18 : 05:44:13
|
| Can insert resultset into a temp table with an identity andselect *, seq = (select coont(*) from #tbl t2 where t2.grp = t.grp and t2.id <= t.id)from #tbl tTo get the sequence in a particular order put a clustered index on the temp table in the order you want it than add the identity.You can also do the same as above using any unique columns in the resultset to do the calculation.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-01-18 : 08:18:36
|
quote: select coont(*)
OK, I'd correct this, but I'm laughing to hard. |
 |
|
|
|
|
|