Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Query needed

$
0
0

declare @temp table(patnum int, rownumber int)
insert into @temp (patnum,rownumber)
select 123,null union
select 123,null union
select 123, null union
select 456, null union
select 456 , null union
select 689 , null

i want incremental numbers to be inserted into rownumber field.  It should start with 1.  Rownumber should change only when PAtno changes.  Can somebody help.
so, the result would be.

Patno Rownumber
123    1
123    1
123    1
456    2
456    2
689    3


NSG12


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>