I am trying to select everything in a table, and also count the number of rows in a table that have the same data.
SELECT *, COUNT(thedate) daycount FROM `table` ORDER BY thedate DESC
My hope is to have one query that outputs the date and number of rows associated with that date, and the looped output will be something like this:
Jan 1, 2000 (2 rows)
col1, col2, col3, col4
col1, col2, col3, col4Jan 1, 2000 (3 rows)
col1, col2, col3, col4
col1, col2, col3, col4
col1, col2, col3, col4Jan 1, 2000 (6 rows)
col1, col2, col3, col4
col1, col2, col3, col4
col1, col2, col3, col4
col1, col2, col3, col4
col1, col2, col3, col4
col1, col2, col3, col4
etc…
Does this make sense?
If you have a table that looks like this:
and you wanted the counts of duplicate col1.. col4 per given day, you would run this query
Here is some sample data and the result of the query:
I’ll leave it to you imaginative creativity to loop through this and print
Give it a Try !!!