SQLZOO
大头力哥
这个作者很懒,什么都没留下…
展开
-
SQLZOO_9 SELF JOIN
1.How many stops are in the database.select count(*) from stops;2.Find the id value for the stop ‘Craiglockhart’select id from stopswhere name='Craiglockhart';3.Give the id and the name for the stops on the ‘4’ ‘LRT’ service.select id,name from sto原创 2020-09-21 17:43:18 · 208 阅读 · 0 评论 -
SQLZOO_8 USING NULL
1.List the teachers who have NULL for their department.select name from teacherwhere dept is null;2.Note the INNER JOIN misses the teachers with no department and the departments with no teacher.SELECT teacher.name, dept.name FROM teacher INNER JOIN原创 2020-09-21 17:41:03 · 206 阅读 · 0 评论 -
SQLZOO_7 MORE JOIN
1.List the films where the yr is 1962 [Show id, title]SELECT id, title FROM movie WHERE yr=19622.Give year of ‘Citizen Kane’.select yr from moviewhere title='Citizen Kane'3.List all of the Star Trek movies, include the id, title and yr (all of the原创 2020-09-21 17:39:17 · 180 阅读 · 0 评论 -
SQLZOO_6 JOIN
1.The first example shows the goal scored by a player with the last name ‘Bender’. The * says to list all the columns in the table - a shorter way of saying matchid, teamid, player, gtimeModify it to show the matchid and player name for all goals scored b原创 2020-09-21 17:36:35 · 224 阅读 · 1 评论 -
SQLZOO_5 SUM and COUNT
1.Show the total population of the world.world(name, continent, area, population, gdp)SELECT SUM(population)FROM world2.List all the continents - just once each.select distinct continent from world3.Give the total GDP of Africaselect sum(gdp) from原创 2020-09-21 17:32:27 · 173 阅读 · 0 评论 -
SQLZOO_4 SELECT within SELECT
1.List each country name where the population is larger than that of ‘Russia’.world(name, continent, area, population, gdp)select name from world where population>(select population from worldwhere name='Russia')2.Show the countries in Europe with原创 2020-09-21 17:26:23 · 219 阅读 · 0 评论 -
SQLZOO_3 SELECT from Nobel
1.Change the query shown so that it displays Nobel prizes for 1950.SELECT yr, subject, winnerFROM nobelWHERE yr = 19502.Show who won the 1962 prize for Literature.SELECT winnerFROM nobelWHERE yr = 1962AND subject = ‘Literature’3.Show the year a原创 2020-09-21 17:17:28 · 308 阅读 · 0 评论 -
SQLZOO_2 SELECT from WORLD
1.Read the notes about this table. Observe the result of running this SQL command to show the name, continent and population of all countries.SELECT name, continent, population FROM world2.How to use WHERE to filter records. Show the name for the countr原创 2020-09-21 17:12:40 · 274 阅读 · 0 评论 -
SQLZOO_1 SELECT basic
1.The example uses a WHERE clause to show the population of ‘France’. Note that strings (pieces of text that are data) should be in ‘single quotes’;Modify it to show the population of GermanySELECT population FROM world WHERE name = 'Germany'2.Checki原创 2020-09-21 17:03:42 · 136 阅读 · 0 评论