I use the following query to count unique pageviews, grouped by date.
$sqlStr = '
date(viewdate) AS myDate,
COUNT(DISTINCT userip) AS myCount
I need to add this part to it, but not sure how.
SUM(earnings) AS mySum WHERE approved='true' DISTINCT userip
The idea is to count all approved earnings from a specific date, but only from unique visitors (my affiliates only get paid per 24 hour unique visitor).