select 部门,工号,姓名,月,工资1, 工资2,工资3 from 表 where 月 in (1,2) order by 部门,工号,月

解决方案 »

  1.   

    select 部门,工号,姓名,月,工资1, 工资2,工资3 from 表 where 工号 in (select a.工号 from 表 a,表 b where a.月=1 and b.月=2 and a.工号=b.工号 and (a.工资1-b.工资1<>0 or a.工资2-b.工资2<>0 or a.工资3-b.工资3<>0)) and 月 in (1,2) order by 部门,工号,月
      

  2.   

    谢谢大力,有事耽搁了一段时间,不好意思。
    不止三个字段,且字段数不固定。不过没关系
    我只想求简练的sql语句。
    我现在试一下。