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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 dynamically generate field with auto number

Author  Topic 

simakas
Starting Member

3 Posts

Posted - 2005-04-08 : 07:38:43
hi,

what should i insert into querie, to get a column with unique result row number
i have managed smth like this:

--------------------------
DROP TABLE top7games

SELECT distinct top 7 data, pavadinimas, identity(smallint,1,1) as game_no
INTO top7games
FROM turnyras
ORDER BY data DESC

SELECT * FROM top7games
--------------------------

the result in column game_no isnt what i expected...

________________
simakas

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-04-08 : 08:19:38
and what do you expect? and what did you get?

Go with the flow & have fun! Else fight the flow
Go to Top of Page

simakas
Starting Member

3 Posts

Posted - 2005-04-08 : 08:28:40
solved that problem with three different queries:

____________________________
drop table top7games

select distinct top 7 data, pavadinimas
into top7games
from turnyras
order by data desc

ALTER table top7games add game_no smallint identity

select * from top7games
____________________________

result: (in lithuanian :) )

data pavadinimas game_no
5.11.2003 Lietuvos pirmenyb#279;s 1
3.16.2002 Lietuvos žiemos pirmenyb#279;s 2
8.20.2001 Palangos Juz#279; 3
6.15.2001 Vilniaus pirmenyb#279;s 4
5.12.2001 Atviros Vilniaus pirmenyb#279;s 5

________________
simakas
Go to Top of Page
   

- Advertisement -