前言:很基础的就不提了,只复盘一些有意思的。
1、Show the countries which have a name
that includes the word 'United'
这题基础可以用 like+% where name like '%United%',但是考虑到like时间较长,可换成instr函数。instr(field,str)返回str在field中的起始下标,0表示没有。not like +% 没有,比如没有空格:not like '% %'
select name from world where instr(name,'United')>0
2、One or the other (but not both);Exclusive OR (XOR). Show the countries that are big by area (more than 3 million) or big by population (more than 250 million) but not both. Show name, population and area.
异或,xor,两条件一真一假则真,同真或同假则假。
select name,population,area from world where area>=3000000 xor population>=250000000
3、ROUND(f,p) returns f rounded to p decimal places,保留p位小数,p可为负数,p为负数时,取整。如Round this value to the nearest 1000。千位取整,round(a