Posts

Showing posts from March, 2015

mysql tips - JOIN and GROUP BY - complex query example

SELECT td.c1, td.c2, sum(tc.c3) FROM   (SELECT tc.*, tb.c1, tb.c2 FROM tb       JOIN (SELECT ta.c1, ta.c2, sum(ta.c3) FROM ta WHERE... GROUP BY...) tc       ON  tb.c4=ta.c5) td GROUP BY td.c1, td.c2