I've just came up with aniother problem of getting a set of results. Finding the latest records, Example:
ID | Mobileno | created |
1 | +90990 | 01-FEB-06 |
2 | +90990 | 02-FEB-06 |
3 | +90991 | 02-FEB-06 |
4 | +90991 | 01-FEB-06 |
The results must be like this , only 1 mobileno with the latest creation date
ID | Mobileno | created |
2 | +90990 | 02-FEB-06 |
3 | +90991 | 02-FEB-06 |
The answer:
select t.*
from (select a.*,dense_rank() over (partition by mobileno order by created desc) dr from my_table a) t
where dr=1;
No comments:
Post a Comment