(SELECT COUNT(*)
FROM [1]
WHERE (性别 = '男') AND (班级 = bj)) AS 男生,
(SELECT COUNT(*)
FROM [1]
WHERE (性别 = '女') AND (班级 = bj)) AS 女生,
(SELECT COUNT(*)
FROM [1]
WHERE (班级 = bj)) AS 总计
FROM (SELECT 班级 AS BJ, *
FROM [1]) DERIVEDTBL
GROUP BY BJ
附,失败的尝试:
SELECT 班级,
(SELECT COUNT(*)
FROM [1] b
WHERE (性别 = '男') AND (b.班级 = 班级)) AS 男生
FROM [1]
GROUP BY 班级
SELECT 班级,
FROM [1]
WHERE (班级 IN
(SELECT DISTINCT 班级
FROM [1]))