(1)
Select count(distinct student_id)
From A
Where score != Null or score !=0
(2)
Select avg(score)
From A
Group by course_name
(3)
Select t1.course_name, t1. 每门课及格人数, t2.每门课不及格人数
From
(
Select course_name, count(distinct student_id) as 每门课及格人数,
From A
Where score >=60
Group by course_name) t1,
(
Select course_name, count(distinct student_id) as 每门课不及格人数,
From A
Where score <60
Group by course_name) t2
Where t1.course_name = t2.course_name
select COUNT(student_id), avg(score), course_name from A GROUP BY course_name 3.select case when score >=60 then 1 when score<60 then 0 else "其他" end as is_pass COUNT(student_id), course_name from A GROUP BY course_name,case when score >=60 then 1 when score<60 then 0 else "其他" end