玩具 - G $ 玩具 - R $ 玩具 - W $ 玩具 - Q 部门编号或玩具编号哦健康 玩具7 0 生育0 2 为什么?! 谢谢解决方案 您不能在DML命令中使用IF语句,您必须使用 CAS E(Transact-SQL) I can't understand because this SQL query doesn't work:SELECT COUNT Department,IF(Department = 'toys', COUNT(), 0) AS numberOfToys,IF(Department = 'health', COUNT(), 0) AS numberOfHealthFROM TABLE;TABLEDepartment - Valuetoys - Atoys - Btoys - Chealth - Khealth - Ftoys - Gtoys - Rtoys - Wtoys - QI'd like to count number of occurrences about both toys record and health ones into 2 columns.department numberOfToys numberOfHealthtoys 7 0health 0 2WHY ?!thanks 解决方案 You can not use an IF Statement within a DML command, you have to use CASE (Transact-SQL) 这篇关于具有count istruction的sql查询结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-27 02:32