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

Enumerate rows in a SQL QUERY with Counter

$
0
0

Hello 
I have a query with UNION 

Select ‘input’ as Type, Name, City, date form Table1
union 
Select ‘Output’ as Type ,Name, City, date  from Table2
ORDER by date

As result, I would like to have a rownumber as part of Query 

1, Input, Peter, New York, Dec-01
2, OutPut, Joseph, California, Dec-03
3, Input, Mary, Atlanta, Dec-09

How can I add a ROW_NUMBER to the query?



Carlos Pelaez


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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