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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-07-10 : 09:02:21
|
| Jenny writes "Hi!This is a sqlstatment select k.fileid, k.name, a.payday from ainner join g on g.gnid = a.gnidinner join k on k.fileid = g.fileidThe output could be2455 Jenny 2001-01-314533 Jenny 2002-02-285744 Henrik 2001-01-311995 Henrik 2000-12-319076 Jenny 2002-03-31etcThis will pick out name, fileid and payday for salaries. I would to temporarily add a unique numeric id connected to the name. Since the primary unique key in table k is the name, I need to keep it like that in the DB, but in this query I want it to be like2455 Jenny 2001-01-31 114533 Jenny 2002-02-28 115744 Henrik 2001-01-31 131995 Henrik 2000-12-31 139076 Jenny 2002-03-31 11where 11 and 13 would be the generated id´s.Hope you have a smart solution for me.Jenny" |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-07-10 : 09:53:15
|
| Could put distinct names into a temp table with an identity then join to that for the output orselect k.fileid, k.name, a.payday, (select count(*) from k k2 where k2.name <= k.name)from a inner join g on g.gnid = a.gnid inner join k on k.fileid = g.fileid ) as a==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|