日期:2014-05-16  浏览次数:20757 次

请教一个sql的查询,有难度。
序号 卡号 支付金额 受理日 创建日期
33 7689600000000710464 20100820 2010/8/20 13:43:41
26 7689600000000645942 2.50 20100820 2010/8/20 13:41:08
2 7689600000000620259 65.75 20100820 2010/8/20 11:54:24
11 7689600000000436532 20100820 2010/8/20 11:56:02
10 7689600000000436532 20100820 2010/8/20 11:56:02
13 7689600000000436532 20100820 2010/8/20 11:56:03
12 7689600000000436532 20100820 2010/8/20 11:56:03
7 7689600000000436532 20100820 2010/8/20 11:55:56
8 7689600000000436532 20100820 2010/8/20 11:55:57
6 7689600000000418423 163.00 20100820 2010/8/20 11:55:42
18 7689600000000000148 0.01 20100820 2010/8/20 11:57:50
19 7689600000000000148 0.01 20100820 2010/8/20 11:58:26
25 7689600000000000148 0.01 20100820 2010/8/20 12:02:00
5 7689600000000000148 0.01 20100820 2010/8/20 11:55:07
3 7689600000000000148 0.01 20100820 2010/8/20 11:54:35
27 7689510053000010509 1517.00 20100820 2010/8/20 13:41:56
31 7689510053000010509 20100820 2010/8/20 13:43:02
32 7689510053000010509 20100820 2010/8/20 13:43:09
17 7689500210000029515 31.00 20100820 2010/8/20 11:57:45
28 7689500210000019961 42.00 20100820 2010/8/20 13:42:00
4 7689500210000009541 20100820 2010/8/20 11:54:53
21 7689500210000004534 28.00 20100820 2010/8/20 12:00:12
24 7689500210000004534 20100820 2010/8/20 12:01:09
34 7689200010172612475 0.02 2011118 2010/12/22 16:57:38
1 7689200010101059632 96.00 20100820 2010/8/20 11:54:00
23 7689200010101013092 20100820 2010/8/20 12:00:49
22 7689200010101013092 20100820 2010/8/20 12:00:48
9 7689200010100848563 20100817 2010/8/17 12:21:43
20 7689200010100780709 20100819 2010/8/19 20:05:56
15 7689200010100151687 20100820 2010/8/20 11:57:44
16 7689200010100151687 20100820 2010/8/20 11:57:44
14 7689100373000116882 71.10 20100820 2010/8/20 11:56:33
... .... ... ... ...

我想把同一卡号的金额统计统计到一起,应该怎么做?
如卡号为7689600000000000148 金额为 0.01+0.01+0.01+0.01+0.01=0.05
卡号非常多。

------解决方案--------------------
select t.卡号,sum(t.金额)
from table_t t
group by t.卡号
------解决方案--------------------
SQL code

--???
select 卡号,sum(支付金额) 支付金额 from t group by 卡号;

------解决方案--------------------
如只是某一类卡号:
select sum(支付金额) from tabnam where 卡号 = '7689600000000000148'
------解决方案--------------------
探讨
引用:

select t.卡号,sum(t.金额)
from table_t t
group by t.卡号

我有n多卡号我不可能全部写完!

------解决方案--------------------
SQL code

select 卡号,
        sum(支付金额) 支付金额 
from tb1 
group by 卡号;