New answers tagged

1 vote
Accepted

Trying to renumber a field in order grouping by another

For an UPDATE query you don't need to rejoin, you can update the derived table directly UPDATE T SET sequence = RowNum FROM ( SELECT T.*, row_number() OVER (PARTITION BY C.co ORDER ...
Charlieface's user avatar
  • 12.9k
0 votes

Trying to renumber a field in order grouping by another

Nailed it! Thank you both, that was just what I needed. Using the following I was able to successfully UPDATE the sequencing in order. UPDATE TNode SET sequence = (SELECT RowNum FROM (SELECT ...
Jonathan Beck's user avatar
0 votes

Is it possible to sort by the sequence of input IDs?

You can use ORDER BY clause with a CASE: SELECT * FROM `songs` ORDER BY CASE WHEN `id` = 3087 THEN 0 WHEN `id` = 5122 THEN 1 ELSE `id` NOT IN (3087, 5122) END ASC In this example, ...
Ahmed Fathy's user avatar
6 votes

Is default ordering affected by clustered index?

here's a demo Yano is of course correct about order not being guaranteed without an order by. This has been written about 6 trillion times across the span of the internet for most if not all of the ...
Erik Darling's user avatar
  • 40.8k
4 votes

Is default ordering affected by clustered index?

Without ORDER BY clause, the order of rows is not guaranteed. It could be the same one day, and different another day. Is default ordering affected by clustered index? Oftentimes, the data are read ...
Yano_of_Queenscastle's user avatar

Top 50 recent answers are included