请教 ,关于 GROUP BY
如下:
方式1
select to_char(dhz_date,'yyyy-mm-dd') as dhz_date
,(select count(distinct vhz_id)
from c_receipt
where vyx_flag ='01'
and to_char(dhz_date,'yyyy-mm-dd') = to_char( DSK_TIME,'yyyy-mm-dd')))
as NSJ_COUNT
,sum(ntotal_fee) ntotal_fee
,sum(NXY_FEE) nxy_fee
where DHz_date between to_Date('2005-1-31','YYYY-MM-DD hh24:mi:ss')
and to_date('2005-3-1','yyyy-mm-dd hh24:mi:ss')
group by to_char(dhz_date,'yyyy-mm-dd')
/
不是 GROUP BY 表达式
方式2
select to_char(dhz_date,'yyyy-mm-dd') as dhz_date
,count((select distinct vhz_id
from c_receipt
where vyx_flag ='01'
and to_char(dhz_date,'yyyy-mm-dd') = to_char( DSK_TIME,'yyyy-mm-dd')))
as NSJ_COUNT
,sum(ntotal_fee) ntotal_fee
,sum(NXY_FEE) nxy_fee
where DHz_date between to_Date('2005-1-31','YYYY-MM-DD hh24:mi:ss')
and to_date('2005-3-1','yyyy-mm-dd hh24:mi:ss')
group by to_char(dhz_date,'yyyy-mm-dd')
/
NSJ_COUNT 数据被成倍汇总 ,如何解决。此sql 是程序补救措施,否则不会这样写
多谢!