select table1.bdsmc,table1.dymc,min(table2.cjsj),decode(bj,'1','手抄','系统采集')bj,sum(table2.bj_zxyg),sum(table2.bj_fxyg),table2.bl from table1,table2 where table1.dybm=1 and table2.dybm=1 and talbe2.fl=0 and table2.cjsj>to_date('2003-7-1 00:00:00','yyyy-mm-dd hh24:mi:ss') group by table1.bdsmc,table1.dymc,table2.bj,table2.bl我改成这样可以在sql*plus中显示了 不过在我前端的delphi中DBGrid显示依然不正常,table2.cjsj,table2.bj_zxyg,table2.bj_fxyg无法显示
select table1.bdsmc,table1.dymc,min(table2.cjsj),decode(bj,'1','手抄','系统采集')bj,sum(table2.bj_zxyg),sum(table2.bj_fxyg),table2.bl from table1,table2 where table1.dybm=1 and table2.dybm=1 and talbe2.fl=0 and table2.cjsj>to_date('2003-7-1 00:00:00','yyyy-mm-dd hh24:mi:ss') group by table1.bdsmc,table1.dymc,table2.bj,table2.bl将 table2.cjsj,table2.bj_zxyg,table2.bj_fxyg 加上别名试试。
改为:
decode(bj,'1,'手抄','系统采集') bj,sum(table2.zxyg),sum(table2.fxyg),table2.bl
table1.bdsmc,table1.dymc,min(table2.cjsj),decode(bj,'1','手抄','系统采集')bj,sum(table2.bj_zxyg),sum(table2.bj_fxyg),table2.bl
from
table1,table2
where
table1.dybm=1 and table2.dybm=1 and talbe2.fl=0 and table2.cjsj>to_date('2003-7-1 00:00:00','yyyy-mm-dd hh24:mi:ss') group by table1.bdsmc,table1.dymc,table2.bj,table2.bl我改成这样可以在sql*plus中显示了
不过在我前端的delphi中DBGrid显示依然不正常,table2.cjsj,table2.bj_zxyg,table2.bj_fxyg无法显示
仔细调试正确后,才可以在程序中调用。
bj_zxyg、bj_fxyg——number
sql*plus已经通过我改动后的sql语句了
table1.bdsmc,table1.dymc,min(table2.cjsj),decode(bj,'1','手抄','系统采集')bj,sum(table2.bj_zxyg),sum(table2.bj_fxyg),table2.bl
from
table1,table2
where
table1.dybm=1 and table2.dybm=1 and talbe2.fl=0 and table2.cjsj>to_date('2003-7-1 00:00:00','yyyy-mm-dd hh24:mi:ss') group by table1.bdsmc,table1.dymc,table2.bj,table2.bl将 table2.cjsj,table2.bj_zxyg,table2.bj_fxyg 加上别名试试。
min(to_number(to_char(table2.cjsj,yyyymmddhh24miss)))
试试。
要注意Delphi和Oracle字段定义时的分歧之处。