Page 1 of 1

Daily queries

Posted: Mon Apr 24, 2006 8:36 am
by hame22
Hi I have a web site which allows members to register to it

When a user regsiters I store the date on whihc they do this.

From this data I now want to display how many memebers have signed up on each day since the site was launched, so I can display something like "2006-04-17 : 13 members" for each day

any ideas what sort of query i should run, was thinkin of using a distinct for the day then counting the number of registartions fromit?

thanks in advance

alex

Posted: Mon Apr 24, 2006 8:45 am
by shiznatix
why not just do:

Code: Select all

SELECT
  *
FROM
  table_name
WHERE
  join_date = $today
and do a count on that or whatever? somthing simple like that

Posted: Mon Apr 24, 2006 9:02 am
by n00b Saibot
Query should be

Code: Select all

SELECT COUNT(*)
FROM
  `table_name`
GROUP BY
  `join_date`;

Posted: Mon Apr 24, 2006 10:29 am
by RobertGonzalez
How is your date stored in the database (unix_timestamp or actual Date/Time value)? At some point in your query you are going to want to make sure that all dates that could be the same are selected along the same format. Then I would suggest using DISTINCT in combination with GROUP BY. As for counting, well, take a look at the queries that were presented in the posts before this for how you would use COUNT in conjunction with DISTINCT to get what you want. If you still need help, post back.