思路:使用WHERE
关键字添加限定条件,用 COUNT
关键字计算人数,用AVG
关键字计算平均值
代码解释:限定数据来自性别为难的记录,然后计算人数以及gpa均值
SELECT
COUNT(gender) AS male_num,
AVG(gpa) AS avg_gpa
FROM
user_profile
WHERE
gender = 'male'
题目:https://www.nowcoder.com/practice/7d9a7b2d6b4241dbb5e5066d7549ca01?tpId=199&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3DSQL%25E7%25AF%2587%26topicId%3D199
标签:COUNT,gender,gpa,关键字,SQL17,男生,male,WHERE
来源: https://www.cnblogs.com/tiansz/p/16465216.html