我有一张表数据结构为
月份 审核状态
2 2
2 2
3 2
3 2
4 2
4 2
现在我需要查询 审核状态为2并且是最近的月份 现在我只能在where 条件处做处理 我如何判断审核为2筛选过后的月份是最近的月份?
------解决方案--------------------
测试了一下是因为没有对from后面的表加别名引起的。where前表别名知道吗?
select * from test_a t1
where verify_status = 2 AND
NOT EXISTS (SELECT 1 FROM test_a t2 WHERE t2.verify_status = t1.verify_status
AND t2.months > t1.months )