SQL17 Calculate the number of boys and average GPA

Original title link

Insert image description here

SELECT
  COUNT(gender) AS male_num,
  AVG(gpa) AS avg_gpa
FROM user_profile
WHERE
  gender = 'male'

The execution order of count(), where, and group by:
first where filtering, then group by grouping and splitting to generate a temporary table, and finally cout summing and merging temporary tables

Guess you like

Origin blog.csdn.net/QinLaoDeMaChu/article/details/127407493