select f.workno,f.name,f.deptid,c.*from fixfield f ,contract c where convert(char,c.EndTime,111) like '%2008/02%' and c.employeeid=f.workno and f.emptype!='退休' and f.emptype!='死亡' and f.emptype!='调出'order by f.workno
需要把工号,去掉工号f.workno重复的项,求高手帮忙!!
需要把工号,去掉工号f.workno重复的项,求高手帮忙!!
需要把工号,去掉工号f.workno重复的项,求高手帮忙!!
----------------------------------------------
workno重复的情况下?假设name不重复(或某个字段)select m.* from
(
select f.workno,f.name,f.deptid,c.*from fixfield f ,contract c where convert(char,c.EndTime,111) like '%2008/02%' and c.employeeid=f.workno and f.emptype!='退休' and f.emptype!='死亡' and f.emptype!='调出'order by f.workno
) m where name = (select max(name) from
(
select f.workno,f.name,f.deptid,c.*from fixfield f ,contract c where convert(char,c.EndTime,111) like '%2008/02%' and c.employeeid=f.workno and f.emptype!='退休' and f.emptype!='死亡' and f.emptype!='调出'order by f.workno
) n where workno = m.workno
)