oralce 根据两个字段排序查询两个字段都排第一的一条数据问题 现在我有一个表,包含年和月两个字段,需要查
oralce 根据两个字段排序查询两个字段都排第一的一条数据问题
现在我有一个表,包含年和月两个字段,需要查询出最新一年中最新一个月的一条数据。SQL语句怎么写呢?
比如
column id year month
1 2013 1
2 2012 1
3 2013 3
4 2012 2
我希望得到ID为3的这条数据。求帮助。
[解决办法]
select * from (
select * from table order by year desc,month desc
)
where rownum=1
