Col0 and Col1 are holding basic stuff
Col2 are age (sorted)
Col3 are category like Male, Female, Child (grouped)
Col4 should be the number Im trying to get from the Select Statement where x
should read as follow: for each group in Col3 I should get 1, 2, 3 then again
1, 2, 3 etc. which is represented in COL5. Consider that has ranking or
positin.
Any idea will be great.
Hi Nicolas,
Try:
SELECT Col0, Col1, Col2, Col3,
RANK() OVER (PARTITION BY Col3 OPRDER BY Col2 DESC) AS Col4
FROM YourTable
ORDER BY Col3, Col4;
(Untested - see www.aspfaq.com/5006 if you prefer a tested reply)
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis