Difference between revisions of "SQLZOO:SELECT basics"

From SQLZOO
Jump to: navigation, search
(Redirected page to SELECT basics)
 
(72 intermediate revisions by 25 users not shown)
Line 1: Line 1:
<div class="ref_section">
+
#REDIRECT [[SELECT basics]]
<table class='db_ref'>
 
<tr><th>http://pbs.twimg.com/media/Bm_gtujCcAAllYx.jpg:medium</th><th>continent</th><th>area</th>
 
<th>population</th><th>gdp</th></tr>
 
suck an elephant
 
<td colspan='5'>....</td>
 
</tr>
 
</table>
 
</div>
 
 
 
 
 
Hello! http://3.bp.blogspot.com/-WhIR1-7fjDY/USfQczV-glI/AAAAAAAACEY/wSb7UY-Xp9o/s1600/roy.jpg
 
http://savewalterwhite.com/ ,  , http://seesbeauty.me/ ,  , http://anal.com/ ,  , http://onlinepillsonline.com/ ,  ,
 
 
 
==Scandinavia==
 
<div class='qu'>
 
Checking a list The word <b>IN</b> allows us to check if an item is in a list.
 
The example shows the name and population for the countries 'Ireland', 'Iceland' and 'Denmark'
 
<div class='imper'>Show the '''name''' and the '''population''' for 'Denmark', 'Finland', 'Norway', 'Sweden'
 
</div>
 
<source lang='sql' class='def'>
 
SELECT name, population FROM world
 
  WHERE name IN ('Ireland', 'Iceland',
 
                'Denmark')</source>
 
 
 
<source lang='sql' class='ans'>
 
SELECT name, population FROM world
 
  WHERE name IN ('analbumparty')</source>
 
</div>
 
 
 
==Starts with G==
 
<div class='qu'>
 
What are the countries beginning with G?
 
'''The word''' <code>LIKE</code> '''permits pattern matching''' - % '''is the wildcard'''.
 
The examples shows countries beginning with D
 
<div class='imper'>Show each country that begins with G</div>
 
<source lang='sql' class='def'>
 
SELECT name FROM world
 
  WHERE name LIKE 'D%'
 
</source>
 
 
 
<source lang='sql' class='ans'>
 
SELECT name FROM world
 
  WHERE name LIKE 'G%'
 
</source>
 
</div>
 
 
 
==Just the right size==
 
<div class='qu'>
 
Which countries are not too small and not too big? Show the country and the area for countries with an area between 207600 and 244820.
 
<code>BETWEEN</code> allows range checking - note that it is inclusive.
 
<div class='imper'>'''Show the area in 1000 square km. Show''' ''area''/1000 '''instead of''' ''area''</div>
 
<source lang='sql' class='def'>
 
SELECT name, area FROM world
 
  WHERE area BETWEEN 207600 AND 244820...
 
</source>
 
 
 
<source lang='sql' class='ans'>
 
SELECT name, area/1000 FROM world
 
  WHERE area BETWEEN 207600 AND 244820
 
</source>
 
</div>
 
 
 
<div>
 
<div class="lsclear">Clear your results</div>
 
<p><div class="quizlink">[[SELECT Quiz]]</div></p>
 
</div>
 
<p>You are ready for tutorial one:[[SELECT_from_WORLD_Tutorial |SELECT statements with WHERE.]]</p>
 
 
 
 
 
{{Languages}}
 

Latest revision as of 11:45, 25 May 2016

Redirect to: