系统:oracle8,delphi 6
使用控件: dbgrid, adoquery
请问各位,通过adoquery从多个表中提取统计数据,如何在adoquery的这个数据集中自动添加一条记录类似"总计"之类的并将所有记录在dbgrid中显示出来?
SQL语句如下:
select chufgj.chi_brf,count(b.visit_type) as "经济贸易", count(c.visit_type) as "科学技术", count(d.visit_type) as "文化体育", count(e.visit_type) as "留学培训", count(f.visit_type) as "劳务输出", count(g.visit_type) as "会议", count(h.visit_type) as "友好访问", count(i.visit_type) as "其他" from chufgj,
(select visit_type,ser_num from tuanz where visit_type='经济贸易') b,
(select visit_type,ser_num from tuanz where visit_type='科学技术') c,
(select visit_type,ser_num from tuanz where visit_type='文化体育') d,
(select visit_type,ser_num from tuanz where visit_type='留学培训') e,
(select visit_type,ser_num from tuanz where visit_type='劳务输出') f,
(select visit_type,ser_num from tuanz where visit_type='会议') g,
(select visit_type,ser_num from tuanz where visit_type='友好访问') h,
(select visit_type,ser_num from tuanz where visit_type='其他') i
where chufgj.ser_num like '182004%P' and chufgj.ser_num=b.ser_num(+)
and chufgj.ser_num=c.ser_num(+)
and chufgj.ser_num=d.ser_num(+)
and chufgj.ser_num=e.ser_num(+)
and chufgj.ser_num=c.ser_num(+)
and chufgj.ser_num=d.ser_num(+)
and chufgj.ser_num=e.ser_num(+)
and chufgj.ser_num=f.ser_num(+)
and chufgj.ser_num=g.ser_num(+)
and chufgj.ser_num=h.ser_num(+)
and chufgj.ser_num=i.ser_num(+)
group by chi_brf
使用控件: dbgrid, adoquery
请问各位,通过adoquery从多个表中提取统计数据,如何在adoquery的这个数据集中自动添加一条记录类似"总计"之类的并将所有记录在dbgrid中显示出来?
SQL语句如下:
select chufgj.chi_brf,count(b.visit_type) as "经济贸易", count(c.visit_type) as "科学技术", count(d.visit_type) as "文化体育", count(e.visit_type) as "留学培训", count(f.visit_type) as "劳务输出", count(g.visit_type) as "会议", count(h.visit_type) as "友好访问", count(i.visit_type) as "其他" from chufgj,
(select visit_type,ser_num from tuanz where visit_type='经济贸易') b,
(select visit_type,ser_num from tuanz where visit_type='科学技术') c,
(select visit_type,ser_num from tuanz where visit_type='文化体育') d,
(select visit_type,ser_num from tuanz where visit_type='留学培训') e,
(select visit_type,ser_num from tuanz where visit_type='劳务输出') f,
(select visit_type,ser_num from tuanz where visit_type='会议') g,
(select visit_type,ser_num from tuanz where visit_type='友好访问') h,
(select visit_type,ser_num from tuanz where visit_type='其他') i
where chufgj.ser_num like '182004%P' and chufgj.ser_num=b.ser_num(+)
and chufgj.ser_num=c.ser_num(+)
and chufgj.ser_num=d.ser_num(+)
and chufgj.ser_num=e.ser_num(+)
and chufgj.ser_num=c.ser_num(+)
and chufgj.ser_num=d.ser_num(+)
and chufgj.ser_num=e.ser_num(+)
and chufgj.ser_num=f.ser_num(+)
and chufgj.ser_num=g.ser_num(+)
and chufgj.ser_num=h.ser_num(+)
and chufgj.ser_num=i.ser_num(+)
group by chi_brf
2.使用enlib控件 就像pb里的datawindow一样方便
把adoquery 设置成缓存模式,在另一
adquery中查出sum,然后append adoquery,
2、写SQL语句如
select a,b,c from yourtable where...
union
select '合计',sum(b) as b,sum(c) as c from youtable where```
前台显示就可以了啊