PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Record Counting
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Record Counting

Réponse
 
LinkBack Outils de la discussion
Vieux 27/10/2007, 11h22   #1
Neil Tompkins
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Record Counting

Hi,

I have a table of records all of which have a timestamp against them like 2007-10-25 10:10:19, and category like red, blue etc and a unique key.

Using a SELECT statement is it possible to retrieve the count and number ofrecords for each day e.g 2007-10-25 for all red, and all blue etc

Thanks.
Neil
__________________________________________________ _______________
Feel like a local wherever you go.
http://www.backofmyhand.com
  Réponse avec citation
Vieux 27/10/2007, 12h53   #2
Ravi Kumar.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Record Counting

Hi Neil,

Try this:

SELECT LEFT(DATE_FIELD_NAME, 10), COLOR_FIELD_NAME, COUNT(T.*) AS CNT FROM
TABLE_NAME GROUP BY LEFT(DATE_FIELD_NAME, 10), COLOR_FIELD_NAME.

Post the table structure if this does not .

Regards,

Ravi

On 10/27/07, Neil Tompkins <neildtompkins@hotmail.com> wrote:
>
> Hi,
>
> I have a table of records all of which have a timestamp against them like
> 2007-10-25 10:10:19, and category like red, blue etc and a unique key.
>
> Using a SELECT statement is it possible to retrieve the count and number
> of records for each day e.g 2007-10-25 for all red, and all blue etc
>
> Thanks.
> Neil
> __________________________________________________ _______________
> Feel like a local wherever you go.
> http://www.backofmyhand.com


  Réponse avec citation
Vieux 27/10/2007, 21h07   #3
Peter Brawley
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Record Counting

Neil,

Do you mean ...

SELECT DATE(datetimecol) AS date,colourcol,COUNT(*)
FROM tbl
GROUP BY date,colourcol;

PB

------

Neil Tompkins wrote:
> Hi,
>
> I have a table of records all of which have a timestamp against them like 2007-10-25 10:10:19, and category like red, blue etc and a unique key.
>
> Using a SELECT statement is it possible to retrieve the count and number of records for each day e.g 2007-10-25 for all red, and all blue etc
>
> Thanks.
> Neil
> __________________________________________________ _______________
> Feel like a local wherever you go.
> http://www.backofmyhand.com
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.15.11/1094 - Release Date: 10/26/2007 8:50 AM
>


  Réponse avec citation
Vieux 28/10/2007, 04h33   #4
Ravi Kumar.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Record Counting

Sorry a correction....

SELECT DISTINCT LEFT(DATE_FIELD_NAME, 10), COLOR_FIELD_NAME, COUNT(T.*) AS
CNT FROM TABLE_NAME T GROUP BY LEFT(DATE_FIELD_NAME, 10), COLOR_FIELD_NAME

Ravi

On 10/28/07, Peter Brawley <peter.brawley@earthlink.net> wrote:
>
> Neil,
>
> Do you mean ...
>
> SELECT DATE(datetimecol) AS date,colourcol,COUNT(*)
> FROM tbl
> GROUP BY date,colourcol;
>
> PB
>
> ------
>
> Neil Tompkins wrote:
> > Hi,
> >
> > I have a table of records all of which have a timestamp against them

> like 2007-10-25 10:10:19, and category like red, blue etc and a unique key.
> >
> > Using a SELECT statement is it possible to retrieve the count and number

> of records for each day e.g 2007-10-25 for all red, and all blue etc
> >
> > Thanks.
> > Neil
> > __________________________________________________ _______________
> > Feel like a local wherever you go.
> > http://www.backofmyhand.com
> >
> > ------------------------------------------------------------------------
> >
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.503 / Virus Database: 269.15.11/1094 - Release Date:

> 10/26/2007 8:50 AM
> >

>


  Réponse avec citation
Vieux 30/10/2007, 21h11   #5
ranjeet walunj
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Record Counting

> > Neil Tompkins wrote:
> > > I have a table of records all of which have a timestamp against them

> > like 2007-10-25 10:10:19, and category like red, blue etc and a unique key.
> > >
> > > Using a SELECT statement is it possible to retrieve the count and number

> > of records for each day e.g 2007-10-25 for all red, and all blue etc


Hi neil.

I would use
SELECT count(colour_field_name) AS Counter,
DATE_FORMAT(datetimecol,'%y-%m-%d') as Date, colour_field_name FROM
table_name GROUP BY Date, colour_field_name;

Regards,
Ranjeet Walunj
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h29.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10020 seconds with 13 queries