I have a mysql table like with the following rows:
id | event_type | occurance_date | ipaddress
I want to get the days, unique visits and total visits / day. This is pretty easy to do with 2 queries but I want to make only one.
So i thought To get the days i can
SELECT DISTINCT(occurance_date) as day FROM statistics WHERE event_type = 'visit'
ORDER BY id DESC LIMIT 14;
To get unique visits / day
SELECT COUNT(DISTINCT(ipaddress)) as unique_visits FROM statistics WHERE occurance_date = '2011-05-11';
To get all visits / day
SELECT COUNT(id) as total_visits FROM statistics WHERE occurance_date = '2011-05-11';
The problem is how can I make a single query to return me the all the days, with unique_visits and total_visits.
(2011-05-11 should be replaced by date, it's just an example)
Any suggestion is more then welcomed.
Thanks.