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

Install MYSQL 5.6 in ubuntu 12.04/14.04 and set password and remote access