Tag Info

New answers tagged

0

You may find that the following index and query rewrite performs better, because it sorts per person rather than once over the whole set, and row estimates are more likely to be accurate: -- Index CREATE INDEX IX_Salaries_PersonId_SalaryDate_Inc_ID_Salary1_Salary2_Salary3 ON rdd.Salaries (PersonId, SalaryDate) INCLUDE (ID, Salary1, Salary2, Salary3); -- ...


4

Try this: CREATE TABLE SortTest (val char(1)) INSERT INTO SortTest VALUES ('A'), ('A'), ('A'), ('B'), ('B'), ('B') SELECT val FROM SortTest ORDER BY row_number() OVER (PARTITION BY val ORDER BY val), val



Top 50 recent answers are included