athletes 表包含运动员姓名,年纪和代表国家。下面哪个查询可以找出代表每个国家最年轻的运动员情况?
A:SELECT name, country, age FROM athletes WHERE (country, age) IN (SELECT country, min(age) FROM athletes GROUP BY country)
B:SELECT name, country, age FROM athletes WHERE (country, age) IN (SELECT min(age), country FROM athletes GROUP BY country)
C:SELECT name, country, age FROM athletes WHERE (country, age) IN (SELECT country, min(age) FROM athletes) GROUP BY country
D:SELECT name, country, age FROM athletes WHERE age IN (SELECT country, min(age) FROM athletes GROUP BY country)
A:select后面写需要选择的列名,from表名,where进行条件选择
使用国家以及年龄进行筛选,要求这个国家和年龄是这个国家里年龄最小的
使用in进行筛选,in后面的数据应为每个国家年龄最小运动员数据,因此从运动员表中选择出国家及最小年龄,以国家进行分组,故A正确!
B由于in后面选择出表的列顺序与in前面查找数据的顺序不同无法得到该结果
故错误!
C将以国家分组放在括号外面导致in后面括号中select语法错误,并且不符合题意
D只以年龄进行in筛选无法确定是哪个国家的运动员,无法得到正确结果