是否也可以计数?我的 UNION 为我提供了所有 4 列中的所有不同值,但现在我需要知道每个值在所有 4 列中出现的次数。如果可能,需要使用库存 SQL。
(SELECT DISTINCT classify1 AS classified FROM class) UNION
(SELECT DISTINCT classify2 AS classified FROM class) UNION
(SELECT DISTINCT classify3 AS classified FROM class) UNION
(SELECT DISTINCT classify4 AS classified FROM class)
ORDER BY classified
回报:
A
B
C
D
E
F
H
需要:
一个 | 3
乙 | 3C
| 4D
| 3
E | 1
楼 | 1
小时| 1