sqlzoo
来源:互联网 发布:金枪鱼软件下载 编辑:程序博客网 时间:2024/05/19 15:20
SELECT within SELECT
1.哪些國家的GDP比Europe歐洲的全部國家都要高呢? [只需列出 name 。] (有些國家的記錄中,GDP是NULL,沒有填入資料的。)
select name from world where gdp > ALL (select gdp from world where continent='Europe' and gdp>0)
2.在每一個州中找出最大面積的國家,列出洲份 continent, 國家名字 name 及面積 area。 (有些國家的記錄中,AREA是NULL,沒有填入資料的。)
SELECT continent, name, area FROM world x WHERE area >= ALL (SELECT area FROM world y WHERE y.continent=x.continent AND area >0)
3.列出洲份名稱,和每個洲份中國家名字按子母順序是排首位的國家名。(即每洲只有列一國)
select continent,name from world a where name = (select name from world b where a.continent = b.continent order by name limit 1)
4.找出洲份,當中全部國家都有少於或等於 25000000 人口. 在這些洲份中,列出國家名字name,continent 洲份和population人口。
SELECT name,continent,population FROM world x WHERE 25000000>=ALL(SELECT population FROM world y WHERE y.continent=x.continent AND population>0)
5.有些國家的人口是同洲份的所有其他國的3倍或以上。列出 國家名字name 和 洲份 continent。
select name,continent from world awhere population >= ALL (select population*3 from world b where a.continent = b.continent and population>0 and a.name!=b.name)
The JOIN operation
3.語句FROM 表示合拼兩個表格game 和 goal的數據。語句 ON 表示如何找出 game中每一列應該配對goal中的哪一列 – goal的 id 必須配對game的 matchid 。 簡單來說,就是
ON (game.id=goal.matchid)
以下SQL列出每個入球的球員(來自goal表格)和場館名(來自game表格)修改它來顯示每一個德國入球的球員名,隊伍名,場館和日期。
SELECT b.player,b. teamid ,a.stadium,a.mdate FROM game a JOIN goal b ON a.id=b.matchid where b.teamid ='GER'
阅读全文
0 0
- sqlzoo
- SQLZOO.NET
- SQLZOO(select basics)writeup
- SQLZOO(Using Null)Writeup
- SQLZOO 练习答案 SELECT_basic_names
- SQLZOO SELECT FROM NOBEL
- SQLZOO SELECT within SELECT
- SQLZOO SUM and COUNT
- SQLZOO JOIN operation
- SQLZOO MORE JOIN OPERATION
- SQLZOO USING NULL
- SQLZOO SELF JOIN
- sqlzoo练习答案--Using Null
- sqlzoo练习答案--Self join
- SQLZOO(SUM and COUNT)Writeup
- SQLZOO(More JOIN operations)Writeup
- SQLZOO(self join)writeup未完
- sqlzoo练习答案--Using Null
- 截取数组中指定内容
- 12月18号
- 后工业时代农业发展
- 九周二次课(12月19日) 17.1 celery简介 17.2 celery小例子
- eclipse快捷键详解
- sqlzoo
- 标准算法整理III
- 《Effective Java》------类和接口(2)
- 从事PHP工作,大家知道在不同的阶段需要掌握哪些技能吗?
- CSDN个人博客阅读评论信息的爬取
- linux如何卸载自带的openJdk,并且安装jdk1.8
- js通过Base64 解析html,后台返回的加密字符串
- 树的同构
- DAY009