初学报表 ~~~老手来帮帮忙啊!(100分)

  • 主题发起人 主题发起人 vic152
  • 开始时间 开始时间
V

vic152

Unregistered / Unconfirmed
GUEST, unregistred user!
是一个主从报表的问题,要求从表的数值字段的平均值的统计. 具体如下:
评估: 1~5之间的整数 ,也可能为空或0
总评估: 某评估中>=1的项的平均值
主表:
合同号 客户 编号
ht1 kh1 bh1
ht2 kh2 bh2
从表:
合同号 编号 评估1 评估2 评估3
ht1 1 2 2 2
ht1 2 3
ht1 3 0
ht2 1 3 4 5
ht2 2 3 0
ht2 3 1

要求实现的报表:
合同号 | 客户 | 评估1 | 评估2 | 评估3 |
------------------------------------------------------------------
ht1 | kh1 | 2 | 2 | 2.5 |
-------------------------------------------------------------------
ht2 | kh2 | 3 | 2.5 | 2.5 |
--------------------------------------------------------------
总计: 2.5 2.25 2.5
----------------------------------------------------------------
问题很详细了 ,,,,,有没高手说一下????很急的~~~~!!!
我的数据库是SQL2000 连接组件是ADOQUERY 报表是QUICKREPORT
谁能帮忙解决 100分一定送上!!!!!!!!!!
 
知道的高手帮帮忙啊 !! 搞定了我把我剩下的121分也送上
 
主表:t1 从表:t2
select t1.合同号,t1.客户,tt2.评估11,tt2.评估22,tt2.评估33 from t1,(select 合同号,avg(评估1) 评估11,avg(评估2) 评估22,avg(评估3) 评估33 from t2 group by 合同号) tt2 where t1.合同号=tt2.合同号
 
试试 Grid++Report, 参考例子CrossTab。主页:http://www.rubylong.cn
 
自己搞定了 汗啊... 121分就当我赚的 呵呵,,,,
SELECT ywht_d.hth,SUM(ywht_d.mj * ywht_cb.mjcb) AS allzmjcb,
AVG(ywht_cb.pg1) AS avpg1, AVG(ywht_cb.pg2) AS avpg2,
AVG(ywht_cb.pg3) AS avpg3, AVG(ywht_cb.pg4) AS avpg4,
AVG(ywht_cb.pg5) AS avpg5,
SUM(ywht_cb.xmje1) AS allxmje1, SUM(ywht_cb.xmje2) AS allxmje2,
SUM(ywht_cb.xmje3) AS allxmje3, SUM(ywht_cb.xmje4) AS allxmje4,
SUM(ywht_cb.xmje5) AS allxmje5
FROM ywht_cb INNER JOIN ywht_d
ON ywht_cb.hth = ywht_d.hth
WHERE (ywht_d.hth=:'hth') GROUP BY ywht_d.hth
 
后退
顶部