åœ¨å‡ å�ƒæ�¡è®°å½•é‡?å˜åœ¨ç�?些相å�Œçš„记录,如何能用SQLè¯?�¥,åˆ é™¤æŽ‰é‡�å¤�çš„å‘?br>1ã€�查找表ä¸??余的é‡�å?记录,é‡�å¤�è?å½•æ˜¯æ ¹æ�®å�•ä¸ªå—æ?(peopleId)æ�¥åˆ¤æ–
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2ã€�åˆ é™¤è¡¨ä¸??余的é‡�å?记录,é‡�å¤�è?å½•æ˜¯æ ¹æ�®å�•ä¸ªå—æ?(peopleId)æ�¥åˆ¤æ–,å�ªç•™æœ‰rowidæœ?å°�的记录
delete from people
where  peopleName in (select peopleName   from people group by peopleName     having count(peopleName) > 1)
and  peopleId not in (select min(peopleId) from people group by peopleName    having count(peopleName)>1)
3ã€�查找表ä¸??余的é‡�å?记录(å?ä¸?—段)
select * from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
4ã€�åˆ é™¤è¡¨ä¸??余的é‡�å?记录(å?ä¸?—段),å�ªç•™æœ‰rowidæœ?å°�的记录
delete from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
5ã€�查找表ä¸??余的é‡�å?记录(å?ä¸?—段),ä¸�包å�«rowidæœ?å°�的记录
select * from vitae a
where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)Â Â Â
6.消除ä¸?ä¸?—段的左边的ç?ä¸?ä½�:
update tableName set [Title]=Right([Title],(len([Title])-1)) where Title like '�'
7.消除ä¸?ä¸?—段的å�³è¾¹çš„ç?ä¸?ä½�:
update tableName set [Title]=left([Title],(len([Title])-1)) where Title like '%�
8.å�‡åˆ 除表ä¸??余的é‡�å?记录(å?ä¸?—段),ä¸�包å�«rowidæœ?å°�的记录
update vitae set ispass=-1
where peopleId in (select peopleId from vitae group by peopleId
Â
select *from r_people_report_bak ppp where 1=1and length(ppp.reporting_period)<=6and ppp.organization_code || '_' ||to_char(to_date(ppp.reporting_period ,'YYYY-mm'),'yyyy') || '-' || to_char(to_date(ppp.reporting_period ,'YYYY-mm'),'mm')|| '_' || ppp.datilor_allin (select pp.organization_code || '_' || pp.aa || '_' || pp.datilor_all from (select p.people_id,p.organization_code,p.datilor_all,to_char(to_date(p.reporting_period ,'YYYY-mm'),'yyyy') || '-' || to_char(to_date(p.reporting_period ,'YYYY-mm'),'mm') aafrom r_people_report_bak p where p.reporting_period is not null ) ppgroup by pp.aa ,pp.organization_code,pp.datilor_allhaving count(1) > 1 )
Â
Â
Â