解决方案 »

  1.   

    那么不能对select后面的选择列做max聚集操作了对吗?
    可以用Not exists达到相同效果。WHERE verify_status = 2 AND NOT EXISTS (SELECT 1 FROM tab t2 WHERE t2.verify_status = verify_status AND t2.months > months )
      

  2.   

    select top 1 *  from tb where 审核状态=2  order by abs(month(getdate())-月份) desc
      

  3.   


    MSSQL可以这样用,点赞!
      

  4.   


    MSSQL可以这样用,点赞!
    不行 我前面根本没法加top 只能在where 后面处理
      

  5.   


    试了你这个  筛选失败 - -
    测试了一下是因为没有对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 )