Reputation: 385
I have a table that is described with two columns: an index, and a date.
How would I run a query so that: for each date, it tallies how many entries are for that date, and does it for every date that appears?
I know I can COUNT for a specific date, but I'm lost as to how to do this for each date.
(I'm using SQLite, but a description for any SQL language would be very helpful). Thanks!
Upvotes: 0
Views: 122
Reputation: 3
If a field is not in the "group by" list then you cannot include it unless you are performing some aggregate function on it (count, sum, etc.).
select "date_field", count(*) from "table" group by "date_field";
Also, SQLite does not have to use backticks (`) like MySQL, you can use double quotes.
Upvotes: -1
Reputation: 1
select index, date, COUNT(*) from tbl
group by index, date
check this.... let me know if it works.....
Upvotes: 0