I have this data:
and I want to this result:
So I ve tried this:
SELECT text_area, ordered_area, RANK () OVER (ORDER BY text_area) ranked_area FROM ( SELECT '1200 AA' text_area ,1 ordered_area FROM DUAL UNION ALL SELECT '1200 AA' ,2 FROM DUAL UNION ALL SELECT '1200 BB' ,3 FROM DUAL UNION ALL SELECT '1200 CC' ,4 FROM DUAL UNION ALL SELECT '1200 CC' ,5 FROM DUAL )
but it did not solve my problem. How can I solve this issue?
thanks in advance
Advertisement
Answer
DENSE_RANK not RANK:
SELECT text_area, ordered_area, DENSE_RANK () OVER (ORDER BY text_area) ranked_area FROM ( SELECT '1200 AA' text_area ,1 ordered_area FROM DUAL UNION ALL SELECT '1200 AA' ,2 FROM DUAL UNION ALL SELECT '1200 BB' ,3 FROM DUAL UNION ALL SELECT '1200 CC' ,4 FROM DUAL UNION ALL SELECT '1200 CC' ,5 FROM DUAL )