i have one table name as a_ad_display with following column
displayId | campaignId | displaytime(date)
1 | 2 | 2012-12-19 12:41:08
2 | 2 | 2012-12-19 01:41:08
3 | 1 | 2012-12-20 10:41:08
4 | 1 | 2012-12-20 02:41:08
5 | 1 | 2012-12-21 12:41:08
6 | 2 | 2012-12-21 01:41:08
7 | 1 | 2012-12-21 12:41:08
8 | 1 | 2012-12-21 02:41:08
there is a multiple entry with same campaignId should be there.now what i want is to first of all fetch the campaignId with the highest count in a_ad_display and for that campaignId i want to get total number of count within the date
eg..from above table i have 1 number campaignId with highest row count
so for 1 number campaignId i want to display records like this..
**Date** | **countPerDay**
2012-12-19 | 0
2012-12-20 | 2
2012-12-21 | 3
how can i achieve this in mysql database…hope anyone can guide me…
You can use this query
Although it will not display 0.
EDIT :
OK This is modified and fetches your result.
Demo
MORE EDITS :
This is how you can select latest 5 records. If you want to select the latest campaign you can use a subquery instead of 1 take a look at this query
EDITS :
I have edited the query this will fetch higher occurance campaignId and fetch results accordingly
Demo