我想创建一个SQL select-query来选择所有内容,但是当client
,thickness
和material
相同时,它们的值为' amount'应该加上。
我如何创建这样的查询?
答案 0 :(得分:6)
如果我理解正确的话。你可以这样做:
SELECT
client,
thickness,
material,
SUM(amount) AS TotalAmount
FROM
Table1
GROUP BY
client,
thickness,
material
答案 1 :(得分:1)
如果是同一列
SELECT
SUM(amount) AS Total
FROM
Tablename
GROUP BY
client,
thickness,
material