I have two different tables, click and click. I would like to query MySQL to get the amount of fees generated by clicks and outputs sorted by date.
Leading:
id|date |commission
1|2009-06-01|400
2|2009-06-01|300
3|2009-06-03|350
Click
id|date |commission
1|2009-06-01|1
2|2009-06-03|2
3|2009-06-03|1
I would like to create a query that gives me (and, if possible, also a date when no lead or click was generated):
date |commission click|commission lead|total commission
2009-06-01| 1| 700| 701
2009-06-02| 0| 0| 0
2009-06-02| 3| 350| 353
(the date is actually datetime in a real database.)
I think I need to combine:
SELECT count(*) as number_clicks, sum(click.commission) as sum_clicks,
date(click.time) as click_date from click group by click_date order by click_date
FROM
SELECT count(*)as number_leads, sum(lead.commission) as sum_leads,
date(lead.time) as lead_date from lead group by lead_date order by lead_date
But I canβt get them to work together.
source
share