use province;#代码开始#第一题select*from jdxx where qxmc="开福区";#第二题select*from jdxx where qxmc in("开福区","岳麓区");#第三题select*from jdxx where cs="长沙市"and name="西湖街道";#代码结束
第二关:查询唯一值
use province
#代码开始selectdistinct qxmc from jdxx where sf="湖南省";selectdistinct qxmc from jdxx where cs="长沙市";#代码结束
第三关:统计查询
use province;#代码开始#答案1selectcount(name)from jdxx where sf="湖南省";#答案selectcount(name)from jdxx where cs="长沙市";selectcount(distinct qxmc)from jdxx where sf="湖南省";selectcount(distinct qxmc)from jdxx where cs="长沙市";
第四关:分组查询
use province;SELECT sf,count(*)FROM jdxx
GROUPBY sf;SELECT cs,count(*)FROM jdxx
GROUPBY cs
HAVINGcount(name)>200;SELECT qxmc,count(*)FROM jdxx
WHERE cs ='长沙市'GROUPBY qxmc;
第五关:数据排序
use province;#代码开始#第一题SELECT*FROM jdtj
ORDERBY jdgs DESCLIMIT10;#第二题SELECT*FROM jdtj
ORDERBY jdgs ASCLIMIT10;#第三题SELECT*FROM jdtj
WHERE jdgs >35ORDERBY jdgs DESC, sf ASC;#代码结束