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.
我需要做一个查询来计算不同值的实例并将它们分组。
SELECT COUNT(*), Type FROM Table GROUP BY Type
Type 的值可以是 C、V 和 I - 但我希望它将任何 I 值视为 V。
所以: C = C V = V I = V
如何在查询中执行此操作?
计算一个等价的字段。下面的CASE语句将采用“I”,将其设为“V”,其他所有内容都不管。
CASE
SELECT COUNT(*), CASE Type WHEN "I" THEN "V" ELSE Type END as NewType FROM Table GROUP BY CASE Type WHEN "I" THEN "V" ELSE Type END