I have a query:
SELECT *
FROM (SELECT COLA,
COLB,
COLC,
COLD,
ROW_NUMBER() OVER(ORDER BY COLA) AS ROWNUMBER
FROM TABLEXYZ)AS Tab1
WHERE ROWNUMBER BETWEEN 1 AND 10
ORDER BY COLA
This query works fine if it has to be sorted on basis of COLA but there are problems if I attempt to sort on a basis of COLB,COLC etc.The sorting does not work.
I want to sort the inner table but the order by clause does not work and thus my sorted results are not accurate.
Try using TOP 100%.