Reply to Re: mysql help needed

Your name:

Reply:


Posted by Paul Lautman on 07/06/06 17:37

Bob Bedford wrote:
> Hi all,
>
>> SELECT count( DISTINCT a.idperson ) , b.region
>> FROM `table1` a
>> JOIN `table2` b
>> USING ( zip )
>> GROUP BY region
>
> Now I've an other question, as I can't get it to work, even with your
> example.
>
> I've a table where there is a datetime field.
>
> I'd like to count the number of articles created every day. How to do
> so ?
> I've tried this:
> select distinct date_format(DateTimeCreation,'%d %m %Y'),
> count(distinct idarticle) from articles group by DateTimeCreation
> order by DateTimeCreation ASC
>
> What I'd like is a table with
> date nbre of creation
> 2006-01-01 3
> 2006-01-02 2
> 2006-01-03 5
> 2006-01-04 7
>
> and so on.....
> actually I've:
> DateTimeCreation
> 2006-01-01 09:11:03
> 2006-01-01 12:01:22
> 2006-01-01 18:42:17
> 2006-01-02 10:27:55
> ....
>
> Thanks for help.
>
> Bob
> select distinct date_format(DateTimeCreation,'%d %m %Y'),
> count(distinct idarticle) from articles group by DateTimeCreation
> order by DateTimeCreation ASC
I'm a bit confused by a bit of this. You say that you want
date nbre of creation
2006-01-01 3
but the date format in your query is day month year?
Try
SELECT count( idarticle ) , left( DateTimeCreation, 10 ) AS created
FROM `articles`
GROUP BY created
or
SELECT count( idarticle ) , date_format(DateTimeCreation,'%d %m %Y') AS
created
FROM `articles`
GROUP BY created

Either should work

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация