fw_id, file_title
6 关于加强上海市安全生产专家管理的补充通知
18 关于什么什么的通知
18 关于什么什么的通知
18 关于什么什么的通知
7 关于对《上海市国民经济和社会发展地十二个五年规划纲要草案(征求意见稿)》修改建议
1 关于提请对上海市安全生产技术支撑体系专业中心市级实验室项目进行审计的函
现在需要将fw_id=18的记录只保留一条,重复记录只保留第一条就可以了,摸索了半天,最终方法如下:
with x as (
select a.*,
(select flow_name from flow where flow_id=a.flow_id) as flow_name
from AM_Fawen a,am_subproject3 b,am_projectlist c,taskcenter d,userlist u
where a.sp3_id=b.sp3_id
and b.sp3_id=c.pl_subprojectid
and b.sp3_tablename=c.pl_subprojecttable
and c.project_id=d.project_id
and ','+cast(u.id as varchar)+',' like d.handlers_assigned
and d.status=0 and b.sp3_projectname like '%%'
and fun_name like '%%'
)
,
y as (
select *,count(fw_id) over (partition by fw_id) r,row_number() over (partition by fw_id order by fw_id) rno from x
)
select * from y where rno=1