<?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=Date_functions&amp;feed=atom&amp;action=history</id>
		<title>Date functions - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://sqlzoo.net/w/index.php?title=Date_functions&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=Date_functions&amp;action=history"/>
		<updated>2013-05-25T09:28:09Z</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=Date_functions&amp;diff=1541&amp;oldid=prev</id>
		<title>Marek: Created page with &quot;Group by day of the week (using date functions) &lt;div class='ht'&gt; &lt;div class=params&gt;schema:gisq&lt;/div&gt; &lt;div&gt; We might want to count, or find the average by days of the week. Thi...&quot;</title>
		<link rel="alternate" type="text/html" href="http://sqlzoo.net/w/index.php?title=Date_functions&amp;diff=1541&amp;oldid=prev"/>
				<updated>2012-07-17T15:14:57Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Group by day of the week (using date functions) &amp;lt;div class=&amp;#039;ht&amp;#039;&amp;gt; &amp;lt;div class=params&amp;gt;schema:gisq&amp;lt;/div&amp;gt; &amp;lt;div&amp;gt; We might want to count, or find the average by days of the week. Thi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Group by day of the week (using date functions)&lt;br /&gt;
&amp;lt;div class='ht'&amp;gt;&lt;br /&gt;
&amp;lt;div class=params&amp;gt;schema:gisq&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
We might want to count, or find the average by days of the week.&lt;br /&gt;
This approach uses the date functions.&lt;br /&gt;
&lt;br /&gt;
'''In this example we note that top of the pops usually&lt;br /&gt;
goes out on a Thursday or Friday.'''&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sql class='tidy'&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=sql class='setup'&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='def e-oracle'&amp;gt;&lt;br /&gt;
SELECT TO_CHAR(wk,'D'), COUNT(song)&lt;br /&gt;
  FROM gisq.totp&lt;br /&gt;
 GROUP BY TO_CHAR(wk,'D')&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang='sql' class='def'&amp;gt;&lt;br /&gt;
SELECT DAYOFWEEK(wk), COUNT(song)&lt;br /&gt;
  FROM totp&lt;br /&gt;
 GROUP BY DAYOFWEEK(wk)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;ecomm e-db2&amp;quot; style=&amp;quot;display: none&amp;quot;&amp;gt;&lt;br /&gt;
DAYOFWEEK gives 1 for Sunday, 2 for Monday,... 7 for Saturday.&lt;br /&gt;
&lt;br /&gt;
An alternative is to use WEEKDAY which gives 0 for Monday, ... 6 for Sunday.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
{{DATE and TIME ref}}&lt;/div&gt;</summary>
		<author><name>Marek</name></author>	</entry>

	</feed>