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

partition by without sorting groupings?

$
0
0

Hi,
I have a problem where I have to use a function like the row_number() function but when I do my groupings I don't want to reorder the whole table.

So the result I want is in the sequence column of the table below:

sitessignaldatesequence
site1alarm2014-05-14 12:001
site1alarm2014-05-14 12:302
site1noalarm2014-05-14 13:001
site1noalarm2014-05-14 13:302
site1noalarm2014-05-14 14:003
site1alarm2014-05-14 14:301
site1alarm2014-05-14 15:002
site2alarm2014-05-14 12:003
site2noalarm2014-05-14 12:301
site2alarm2014-05-14 13:001
site2noalarm2014-05-14 13:301
site2noalarm2014-05-14 14:002



So to desribe what I am trying to do,I want to group by sites order by date. Then I want to sequence the signals, retaining their date ordering.

How can I do this?
Thanks


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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