Re: Add Column Of Days From Date
Posted: Fri Jun 20, 2008 5:32 pm
Shouldn't there be? One for the main query and one for the derived table? (thanks for all the help so far btw)arborint wrote:Now you have two FROM clauses...
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Shouldn't there be? One for the main query and one for the derived table? (thanks for all the help so far btw)arborint wrote:Now you have two FROM clauses...
Tried it a few different ways;arborint wrote:I don't think you can use 'count' as a column name without quoting because it is a reserved word.
Code: Select all
SELECT DAYNAME( `date` ) AS day, AVG(theCount) FROM (SELECT COUNT( * ) as theCount , DAYNAME( `date` ) AS day FROM phonelog2 WHERE DAYNAME( `date` )="Monday" GROUP BY `date`) phonelog2Code: Select all
SELECT DAYNAME( `date` ) AS day, AVG('Count') FROM (SELECT COUNT( * ) as 'Count' , DAYNAME( `date` ) AS day FROM phonelog2 WHERE DAYNAME( `date` )="Monday" GROUP BY `date`) phonelog2Code: Select all
SELECT DAYNAME( `date` ) AS day, AVG('theCount') FROM (SELECT COUNT( * ) as 'theCount' , DAYNAME( `date` ) AS day FROM phonelog2 WHERE DAYNAME( `date` )="Monday" GROUP BY `date`) phonelog2