Difference between revisions of "MoL Chapter 8 Lab"

From SQLZOO
Jump to: navigation, search
Line 8: Line 8:
 
<source lang='sql' class='ans'>
 
<source lang='sql' class='ans'>
 
SELECT *
 
SELECT *
 +
  FROM weather
 +
WHERE station='stornoway' AND yr=1892
 +
</source>
 +
</div>
 +
 +
<div class='qu'>
 +
<div class=imper>What output do you expect from this query? Notice that some values are missing in the tmin column for this year and station.</div>
 +
<source lang='sql' class='def'>
 +
SELECT COUNT(tmin), COUNT(tmax)
 +
  FROM weather
 +
WHERE station='stornoway' AND yr=1892
 +
</source>
 +
<source lang='sql' class='ans'>
 +
SELECT COUNT(tmin), COUNT(tmax)
 
   FROM weather
 
   FROM weather
 
  WHERE station='stornoway' AND yr=1892
 
  WHERE station='stornoway' AND yr=1892
 
</source>
 
</source>
 
</div>
 
</div>

Revision as of 14:41, 22 December 2015

List all details from the weather table for stornoway for 1887 so that you can see the NULL value
SELECT *
  FROM weather
 WHERE station='stornoway' AND yr=1892
SELECT *
  FROM weather
 WHERE station='stornoway' AND yr=1892
What output do you expect from this query? Notice that some values are missing in the tmin column for this year and station.
SELECT COUNT(tmin), COUNT(tmax)
  FROM weather
 WHERE station='stornoway' AND yr=1892
SELECT COUNT(tmin), COUNT(tmax)
  FROM weather
 WHERE station='stornoway' AND yr=1892