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

Weird Question About OVER PARTITION BY Query

$
0
0

I guess today is just my day to be confused...I feel really stupid as i've used the OVER (PARTITION) clause quite a bit.

I'm wondering why my query isn't returning row numbers properly, i'm getting 1's when I should be getting 1,2, 3, etc.  I don't understand.  I have a very simple DDL which I created for test, take a look -

DROP TABLE #Table

CREATE TABLE #Table
(
	IssueID			INT 
	,DateUpdated	DATE
)

INSERT INTO #Table VALUES (1324, '2014-02-02')
INSERT INTO #Table VALUES (1463, '2014-02-07')

SELECT 
	ROW_NUMBER() OVER (PARTITION BY IssueID ORDER BY DateUpdated) as RowNumber
	,IssueID
	,DateUpdated
FROM #Table

Again, this doesn't make sense to me.  How can I get the two records to return a sequential row number starting at 1?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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