..::TrickDD.com::..

SQL query from 2 tables before do another operation

March 21, 2017 Trickdd
No Comments

SQL (firstly, query from 2 tables before do another operation)

SELECT fields & operation FROM (SQL query for table1) as alias table1 name INNER JOIN (SQL query for table2) as alias table2 name on alias table1 name.field=alias table2 name.field GROUP BY alias table1 name. field


for example

SELECT t1.P60_GIndusE, (SUM(t2.LG)-SUM(t1.LG)) as LG FROM (SELECT P60_GIndusE, SUM(LG) as LG FROM table_6001 WHERE ContSize = ‘Test’ GROUP BY P60_GIndusE order by sum(Principal) DESC) as t1 INNER JOIN (SELECT P60_GIndusE, SUM(LG) as LG FROM table_6002 WHERE ContSize = ‘Test’ GROUP BY P60_GIndusE order by sum(Principal) DESC) as t2 on t1.P60_GIndusE=t2.P60_GIndusE GROUP BY t1.P60_GIndusE

SQL 2anotherbeforedofromoperationquerySQLtables
Previous Post

Refund Tax for songkran festival 2016

Next Post

Excel indirect formula

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Proudly powered by WordPress | Theme: Fmi by Forrss.