根据条件选择分组

时间:2017-12-25 20:35:39

标签: sql-server

https://i.stack.imgur.com/8otLv.jpg

我想选择名字 当sum(Productivity)> = 3000和Date =' 2017-12-25' 按机器分组

1 个答案:

答案 0 :(得分:3)

GROUP BYSUM一起使用HAVING

SELECT
  names,
  Machines
FROM Table1
where Date = '2017-12-25'
group by names, Machines 
HAVING sum(Productivity) >= 3000;