diff --git a/新建 文本文档(1).txt b/新建 文本文档(1).txt new file mode 100644 index 0000000..c1470cf --- /dev/null +++ b/新建 文本文档(1).txt @@ -0,0 +1,112 @@ +第1关:按条件查询单表的所有字段 +1.use province; +2#代码开始 +select*from jdxx where qxmc="开福区"; +select* from jdxx where qxmc in("开福区","岳麓区"); +select*from jdxx where cs="长沙市" and name="西湖街道"; +#代码结束 +第2关:查询唯一值 +1.use province +2.#代码开始 +select distinct qxmc from jdxx where sf="湖南省" +select distinct qxmc from jdxx where cs="长沙市"; +#代码结束 +第3关:统计查询 +1. use province; +2.#代码开始 +答案1 +select count(name)from jdxx where sf="湖南省";塔案2 +select count(name)from jdxx where cs="长沙市" +7.答案3 +8.select count(distinct gxmc)from jdxx where sf="湖南省"; +9.答案4 +10.select count(distinct qxmc)from jdxx where cs="长沙市”; +第4关:分组查询 +use province; +2.#代码开始 +3.#题目1 +select sf,count(*)from jdxx group by sf;#题目2 +select cs,count(*)from jdxx group by cs having count(*)>200; +#题目3 +8.select qxmc,count(*)from jdxx where cs="长沙市" group by qxmc; +第5关:数据排序 +use province; +#代码开始 +#第-题 +select*from jdtj order by jdgs desc limit 10; +#第二题 + +selectfrom jdtj order by jdgs asc limit 10; +#第三题 +selectfrom jdtj where jdgs>35 order by jdgs desc,sf; +#代码结束 + +t2 + +第1关:nuIl值的判断 +1. use library; +2.#代码开始 +3. select * from borrow where hsrg is null; + +第2关:between and和in运算 +1use library +#代码开始 +答案1 +select txm,sm,sj from book where sj between 10 and 20; +答案2 +select txm,sm,cbs from book where cbs not in("中华书局”,"上海古籍出版社”); +第3关:like运算符 +use library; +#代码开始 +第一问 +4.select txm,sm from book where sm like"%寺%"; +第二问 +select txm,sm from book where sm like"诗%" +第4关:逻辑运算符 +use library;1. +2.#代码开始 +3.第一问 +select *from reader where xb='男'and sf="研究生"; +第二问 +select * from reader where xb='男'and(sf="研究生"or sf="工作人员"); + +T3 +第1关:数值函数 +use sale; +2.#代码开始 +第一题笞案 +select gyxm,round(gz*0.05,0)as kf from gzry; +第二题笞案 +select gyxm,truncate(gz*0.05,0) as kf from gzry; +第2关:字符串函数一 +.use sale +2.#代码开始 +3.答案1 +select concat(rpad(bm,4," "),rpad(gyxm,4,""),dh)as ygxx from gzry order by bm; +6.select gyxm,dh from gzry where left(gyxm,1)="王" and char length(gyxm)=3; +第3关:字符串函数二 +use sale;1. +#代码开始 +3.第一问 +select insert(name,2,0,space(2*(3-char length(name))) as xm from gk; +第二问select name,concat(left(tel,3),"_",mid(tel,4,4),"_",right(tel,4))as dh from gk;0. +第三问 +8.update gk set dept=replace(dept,"新一佳”,"佳惠”); +18.select name,dept from gk; +第4关:日期函数 +use sale; +#代码开始2 +3.答案1 +4.select month(xsrg)as yf,sum(sjfk)as sije from xsd where year(xsrg)=2015 group by month(xsrg); +5. use library; +答案2 +6.select dzzh,(datediff(hsrg,jyrg)-30)*sj*,01 as fk from borrow,book +where book.txm=borrow.txm +and datediff(hsrg,jyrg)>30; +第5关:条件函数 +.use sa1e: +#代码开始2. +第一题3. +4. select gyxm,if(gz<2000,50,100)as jq from gzry; +第二题5. +6.select gyxm,case bm when "销售部”then 1000 when "办公室”then 800 when "采购部”then 500 else 380 end as jt from gzry;