如何仅对“分组依据”求和而不在何处?
编辑:
如何绑定此内容:
SELECT SUM(sent) FROM cars GROUP BY model_name
到(无处)
良好的SQL:
SELECT *
FROM cars
WHERE status in(0, 1)
GROUP BY model_name
HAVING is_ref = 0
答案 0 :(得分:0)
这应该是您所追求的。只需选择要分组的列,然后按该列分组即可。另外,由于您不聚合is_ref,因此可以将其插入where子句中。
SELECT model_name, sum(sent) as total FROM cars WHERE status
in(0, 1) GROUP BY model_name having is_ref=0
答案 1 :(得分:0)
这是一种方法-
var companyFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Company",
column: "Company ID"
},
operator: 'In',
values: [1]
};
答案 2 :(得分:0)
您在寻找这样的东西吗?
SELECT model_name,
SUM
(
CASE
WHEN (status IN(0, 1) AND is_ref = 0) THEN sent
ELSE 0
END
) [Total]
FROM cars
GROUP BY model_name