Ordering Data
USE AdventureWorksDW2019MSDS
--One Column
SELECT FirstName, LastName
FROM dw.DimEmployee
WHERE 1 = 1
AND IsMostRecentRecord = 1
ORDER BY LastName ASC
--More Than One Column
SELECT FirstName, LastName
FROM dw.DimEmployee
WHERE 1 = 1
AND IsMostRecentRecord = 1
ORDER BY FirstName, LastName ASC
--One Column Descending And Ascending
SELECT FirstName, LastName
FROM dw.DimEmployee
WHERE 1 = 1
AND IsMostRecentRecord = 1
ORDER BY LastName ASC
--One Column Descending
SELECT FirstName, LastName
FROM dw.DimEmployee
WHERE 1 = 1
AND IsMostRecentRecord = 1
ORDER BY LastName DESC
--Multi-Column With Mixed Ordering
SELECT FirstName, LastName
FROM dw.DimEmployee
WHERE 1 = 1
AND IsMostRecentRecord = 1
ORDER BY FirstName ASC, LastName DESC
Last updated