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

Comments

Popular posts from this blog

install ipython in Cloudera VM using pip

install postgreSQL in ubuntu 16.04

Qlikview tips - how to escape characters and space LOAD INLINE table