sql語句,乙個sql語句

時間 2022-04-30 21:30:13

1樓:

select intol.gno,sum(outl.amount),sum(intol.

amount) from intol,outl where intol.gno = outl.gno group by intol.

gno順便說下這種寫法如果intol和outl中gno相同記錄有多個時,得出的sum是錯誤的值,如intol中 有 no1 100 與no1 200 兩條記錄,outl也有no1 150 no1 120兩條記錄,這樣這個格式的語句執行後會得出 no1 600 540這樣的結果,而不是你想要的no1 300 270

2樓:

你要指定gno是多表中的具體表名,是intol還是outl。

3樓:匿名使用者

select outl.gno,outl.sum(amount),intol.sum(amount) from

(select * from intol inner join outl on intol.gno = outl.gno

)group by outl.gno

求教SQL語句寫法,求教乙個SQL語句寫法

這裡給出的pl sql語法 select 化學,物理 from table where 數學 select max 數學 from table 這已經在oracle上測試過 補充 既然是oracle你沒必要建乙個動態的檢視!如果實時要求不高的話,建議你用oracle的固化檢視!查詢化學和物理成績以總...

SQL語句問題,SQL語句問題

select identity int,1,1 as newid,sale.prtid as id,products.prtname as 商品名稱,sum sale.prtnum as 銷售總量 into a from sale,products where sale.prtid products...

如何SQL建立表,sql語句 如何建立乙個表啊

use test go create table dbo article goodid varchar 50 not null,goodname varchar 100 null,price numeric 18,10 not null,goodsum nchar 10 null,constrain...