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.
我在表格中有一个项目列表,我正在对名称进行分组以获得总和。其中一些项目的名称为 NULL,我不想将它们组合在一起。
尝试这个:
SELECT itemname, SUM(whatever) FROM tab WHERE itemname IS NOT NULL GROUP BY itemname UNION ALL SELECT itemname, whatever FROM tab WHERE itemname IS NULL