Sign-up....

帮忙写一段简单的SQL语句(急,在线等回复)

有表A

A表中 有3个字段,number ,money,kouben, code(主键)

现在我想取出 A表中sum(money) 和number 要把number相同并且kouben相同的money求和

[113 byte] By [msdn] at [2007-8-14 15:31:44]
# 1 Re: 帮忙写一段简单的SQL语句(急,在线等回复)

不是很清楚你说的,不知可以不:

select sum(money)

from a

group by number,kouben;

soniczck at 2005-2-19 14:17:00 >
# 2 Re: 帮忙写一段简单的SQL语句(急,在线等回复)

要把number相同并且kouben也同时相同的money求和

dalianu at 2005-2-19 14:28:33 >
# 3 Re: 帮忙写一段简单的SQL语句(急,在线等回复)

select number,kouben,sum(money)

from a

group by number,kouben

onejune4450 at 2005-2-19 14:30:52 >
# 4 Re: 帮忙写一段简单的SQL语句(急,在线等回复)

同意楼上

dy_yong at 2005-2-19 15:36:53 >
# 5 Re: 帮忙写一段简单的SQL语句(急,在线等回复)

--try

select number,kouben,sum(money) from

(

select number,kouben,money from a

group by number,koubeh having count(9)>1

)

group by number,kouben;

ORARichard at 2005-2-19 15:47:45 >
# 6 Re: 帮忙写一段简单的SQL语句(急,在线等回复)

to OraRichard .

你的sql 中的having count(9) 中的参数9 是什么意思,不太明白。

microd at 2005-2-19 16:04:24 >
# 7 Re: 帮忙写一段简单的SQL语句(急,在线等回复)

我想应该是having count(*)> 1吧 :)

lee_billiy at 2005-2-20 13:02:59 >

Oracle

All Classified