求助,同志们帮我分析下两个sql语句有什么不同。
我想用第2个语句力的 科室名称ksmc取代 语句1 的科室代码ksdm,其他不变。
但是查询结果是语句2的记录条数少了很多。麻烦各位高手帮我分析一下,谢谢。!
select fyxh,fymc,zxks,sum(fysl),fydj,sum(zjje) from zy_fymx_cy
where fyrq > to_date('2008-1-1 00:00:00','yyyy-mm-dd hh24:mi:ss')
and fyrq < to_date('2008-2-1 00:00:00','yyyy-mm-dd hh24:mi:ss')
and fyxh in (select fyxh from temp)
group by fyxh,fymc,zxks,fydj;
select a.fyxh,a.fymc,b.ksmc,sum(a.fysl),a.fydj,sum(a.zjje) from zy_fymx a ,gy_ksdm b
where a.fyrq > to_date('2008-1-1 00:00:00','yyyy-mm-dd hh24:mi:ss')
and a.fyrq < to_date('2008-2-1 00:00:00','yyyy-mm-dd hh24:mi:ss')
and a.fyxh in (select temp.fyxh from temp)
and a.zxks = b.ksdm
group by a.fyxh,a.fymc,b.ksmc,a.fydj;