I have one query which is returning
name(text), total, created_at
And another query which is returning the same thing
name(text), total, created_at
The second query usually is returning more rows, but I only need the rows where the query1.created_at = query2.created_at
Example:
Query 1 returns:
test, 10, 2015-03-06
test, 12, 2015-03-07
Query 2 returns:
newtest, 14, 2015-03-05
newtest, 15, 2015-03-06
newtest, 9, 2015-03-07
The expected output:
test, 10, 2015-03-06
test, 12, 2015-03-07
newtest, 15, 2015-03-06
newtest, 9, 2015-03-07
QUERY 1:
SELECT
co.name
sum(c.total)
c.created_at
FROM c_report c
INNER JOIN contact co on co.id = c.contact_id
GROUP BY co.name, c.created_at
QUERY 2:
SELECT
po.name
sum(p.total)
p.created_at
FROM p_report p
INNER JOIN person po on po.id = p.person_id
GROUP BY po.name, p.created_at
INNER JOIN c.contact
? You have a schema namedc
? Or typo? Andpe.name
is supposed to bepo.name
, right?