<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://sqlzoo.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://sqlzoo.net/w/index.php?title=The_nobel_table_can_be_used_to_practice_more_SUM_and_COUNT_functions.&amp;feed=atom&amp;action=history</id>
		<title>The nobel table can be used to practice more SUM and COUNT functions. - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://sqlzoo.net/w/index.php?title=The_nobel_table_can_be_used_to_practice_more_SUM_and_COUNT_functions.&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=The_nobel_table_can_be_used_to_practice_more_SUM_and_COUNT_functions.&amp;action=history"/>
		<updated>2013-05-24T02:47:13Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.4</generator>

	<entry>
		<id>http://sqlzoo.net/w/index.php?title=The_nobel_table_can_be_used_to_practice_more_SUM_and_COUNT_functions.&amp;diff=815&amp;oldid=prev</id>
		<title>Connor at 10:33, 11 July 2012</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=The_nobel_table_can_be_used_to_practice_more_SUM_and_COUNT_functions.&amp;diff=815&amp;oldid=prev"/>
				<updated>2012-07-11T10:33:33Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 10:33, 11 July 2012&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 151:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 151:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;p&amp;gt;&lt;/del&gt;GROUP BY yr, subject&amp;lt;/p&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;GROUP BY yr, subject&amp;lt;/p&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class='qu'&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;div class='qu'&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Show the year and subject where 3 prizes were given. Show only years 2000 onwards.&amp;#160; &amp;#160; &amp;#160;  &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Show the year and subject where 3 prizes were given. Show only years 2000 onwards.&amp;#160; &amp;#160; &amp;#160;  &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Connor</name></author>	</entry>

	<entry>
		<id>http://sqlzoo.net/w/index.php?title=The_nobel_table_can_be_used_to_practice_more_SUM_and_COUNT_functions.&amp;diff=803&amp;oldid=prev</id>
		<title>Connor: Created page with &quot; &lt;h3&gt;Nobel Prizes: Aggregate functions&lt;/h3&gt;   &lt;p&gt;This tutorial concerns aggregate functions such as &lt;code&gt;COUNT&lt;/code&gt;,   &lt;code&gt;SUM&lt;/code&gt; and &lt;code&gt;AVG&lt;/code&gt;.&lt;/p&gt;   &lt;h2&gt;Exer...&quot;</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=The_nobel_table_can_be_used_to_practice_more_SUM_and_COUNT_functions.&amp;diff=803&amp;oldid=prev"/>
				<updated>2012-07-11T09:45:47Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot; &amp;lt;h3&amp;gt;Nobel Prizes: Aggregate functions&amp;lt;/h3&amp;gt;   &amp;lt;p&amp;gt;This tutorial concerns aggregate functions such as &amp;lt;code&amp;gt;COUNT&amp;lt;/code&amp;gt;,   &amp;lt;code&amp;gt;SUM&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;AVG&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;   &amp;lt;h2&amp;gt;Exer...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; &amp;lt;h3&amp;gt;Nobel Prizes: Aggregate functions&amp;lt;/h3&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;This tutorial concerns aggregate functions such as &amp;lt;code&amp;gt;COUNT&amp;lt;/code&amp;gt;,&lt;br /&gt;
  &amp;lt;code&amp;gt;SUM&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;AVG&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;h2&amp;gt;Exercises&amp;lt;/h2&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
Using [http://sqlzoo.net/w/index.php/Using_SUM,_Count,_MAX,_DISTINCT_and_ORDER_BY SUM, COUNT, MAX, AVG, DISTINCT and ORDER BY.]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Show the total number of prizes awarded. &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
SELECT COUNT(winner) FROM nobel&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT COUNT(winner) FROM nobel&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
List each subject - just once  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT DISTINCT subject FROM nobel&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Show the total number of prizes awarded for Physics.&lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT COUNT(subject) FROM nobel&lt;br /&gt;
  WHERE subject='Physics'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using [http://sqlzoo.net/w/index.php/Using_GROUP_BY_and_HAVING. GROUP BY and HAVING.]&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
For each subject show the subject and the number of prizes. &lt;br /&gt;
 nobel('''yr,subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT subject, COUNT(winner)&lt;br /&gt;
  FROM nobel&lt;br /&gt;
 GROUP BY subject&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
For each subject show the first year that the prize was awarded.  &lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT subject, MIN(yr)&lt;br /&gt;
  FROM nobel&lt;br /&gt;
 GROUP BY subject&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
For each subject show the number of prizes awarded in the year 2000.  &lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT subject,COUNT(yr)&lt;br /&gt;
FROM nobel&lt;br /&gt;
WHERE yr=2000&lt;br /&gt;
GROUP BY subject&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Look into [[aggregates with DISTINCT]].&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Show the number of different winners for each subject.   &lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT subject,COUNT(DISTINCT winner)&lt;br /&gt;
FROM nobel&lt;br /&gt;
GROUP BY subject&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
For each subject show how many years have had prizes awarded.    &lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT subject,COUNT(DISTINCT yr)&lt;br /&gt;
FROM nobel&lt;br /&gt;
GROUP BY subject&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using HAVING.&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Show the years in which three prizes were given for Physics.    &lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT yr&lt;br /&gt;
FROM nobel&lt;br /&gt;
WHERE subject='Physics'&lt;br /&gt;
GROUP BY yr&lt;br /&gt;
HAVING COUNT(winner)=3&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Show winners who have won more than once.     &lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT winner&lt;br /&gt;
FROM nobel&lt;br /&gt;
GROUP BY winner&lt;br /&gt;
HAVING COUNT(yr) &amp;gt; 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Show winners who have won more than one subject.      &lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT winner&lt;br /&gt;
FROM nobel&lt;br /&gt;
GROUP BY winner&lt;br /&gt;
HAVING COUNT(DISTINCT subject)&amp;gt;1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;GROUP BY yr, subject&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;div class='qu'&amp;gt;&lt;br /&gt;
Show the year and subject where 3 prizes were given. Show only years 2000 onwards.       &lt;br /&gt;
 nobel('''yr, subject, winner''')  &lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='ans'&amp;gt;&lt;br /&gt;
SELECT yr,subject&lt;br /&gt;
FROM nobel&lt;br /&gt;
WHERE yr&amp;gt;=2000&lt;br /&gt;
GROUP BY yr,subject&lt;br /&gt;
HAVING COUNT(winner)=3&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Connor</name></author>	</entry>

	</feed>