标题:求助.SQL公式运算问题!
取消只看楼主
sbjtg
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-12-21
 问题点数:0 回复次数:1 
求助.SQL公式运算问题!
例如:
SELECT *
FROM (SELECT TOP 5 *
        FROM (SELECT TOP 5 OP_pati_in_me.d_input_time,
                      OP_pati_in_me.d_out_time,
                      OP_pati_in_me.s_me_name,
                      OP_pati_in_me.s_me_type,
                      OP_pati_in_me.n_me_price,
                      OP_pati_in_me.n_me_number,
                      OP_pati_in_me.s_dose_unit,
                      OP_pati_in_me.s_me_unit,
                      OP_pati_in_me.s_ctor_input,
                      OP_pati_in_me.s_ance_mark,
                      OP_pati_in_me.s_charge_mark,
                      OP_pati_in_me.s_dell_mark,
                      OP_pati_in_me.s_yb_update,
                      OP_pati_in_me.s_reckon_mark,
                      OP_pati_man.s_office_now
                FROM OP_pati_in_me, HIS_pati_account,
                      OP_pati_man
                WHERE OP_pati_in_me.d_out_time >= '2011-12-20' AND
                      OP_pati_in_me.d_out_time <= '2011-12-23' AND
                      OP_pati_in_me.s_me_name = '洛希' AND
                      OP_pati_man.s_ctor_residency = '陈忠' AND
                      (OP_pati_in_me.s_ic_no = OP_pati_account.s_ic_no) AND
                      (OP_pati_man.s_hotl_no = OP_pati_in_me.s_hotl_no)
                       AND (OP_pati_in_me.s_ic_no = OP_pati_man.s_ic_no)
                ORDER BY OP_pati_in_me.d_input_time ASC) AS table_1
        ORDER BY d_input_time DESC) table_2
ORDER BY d_input_time

得出结果A1 B1 C1 D1 E1 F1
我要得到所有A1数量相加的和.这个公式怎么写?
2011-12-23 19:02
sbjtg
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-12-21
得分:0 
select SUM(op_pati_out_me.n_me_number)  FROM op_pati_out_me WHERE op_pati_out_me.d_out_time >= '2011-12-20' AND
                      op_pati_out_me.d_out_time <= '2011-12-21' AND op_pati_out_me.s_me_name = '洛希'

原来这样就能直接计算机出来.总算想出来了.

向程序员们致敬,以你们为目标,努力学习,还请多加指点!
2011-12-23 21:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-358482-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.585359 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved