Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我怎样才能让这个查询使用正确的语法?(MySQL)
谢谢你。
SELECT (count(a) WHERE a = 1)-(count(a) WHERE a = 0) FROM table
试试这个。
SELECT SUM(CASE WHEN a=1 THEN 1 ELSE 0 END)- SUM(CASE WHEN a=0 THEN 1 ELSE 0 END) AS Result FROM table