📜  sql group by sum with condition - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:54.032000             🧑  作者: Mango

代码示例1
SELECT CityID, 
       COUNT(*) NumberOfDogsInThisCity,
       SUM(CASE WHEN DogName = 'Tedy' THEN Wheight ELSE 0 END) WheightOfAllDogWithNameTedy
FROM Dogs
GROUP BY CityID