intrigued_66
intrigued_66

Reputation: 17248

Partition BY.... ORDER BY more than one column?

When using PARTITION BY, in the ORDER BY clause is it possible to order based upon more than one column, like a normal ORDER BY statement?

SELECT * , ROW_NUMBER() OVER (PARTITION BY Col0 ORDER BY Col1, Col2) 

I seem to be getting errors when I ORDER BY more than one column

Upvotes: 0

Views: 4563

Answers (1)

Lamak
Lamak

Reputation: 70648

Of course you can, there is no problem with your query and I'm betting that if you say to be seem to be getting errors is because you are actually running the query with no actual errors but obtaining different values than the ones you expected. Those are not errors. If you want us to help you obtaining the values you want, then you need to change your question to reflect that.

Upvotes: 1

Related Questions