轉自:http://www.maomao365.com/?p=7205 摘要: 下文分享兩條sql求和腳本,再次求和的方法分享 ...
轉自:http://www.maomao365.com/?p=7205
摘要:
下文分享兩條sql求和腳本,再次求和的方法分享
/* 例: 下文已知兩條sql求和腳本,現需對兩張不同表的求和記錄再次求和 */ ---對兩條求和sql腳本求和的方法 select sum(q) from ( select sum(qty) as q from tableNameA where ... union all select sum(qty) as q from tableNameB where ... ) as table ---對多條求和sql腳本,再次求和的方法分享 select sum(q) from ( select sum(qty) as q from tableNameA where ... union all select sum(qty) as q from tableNameB where ... union all select sum(qty) as q from tableNameC where ... union all select sum(qty) as q from tableNameD where ... ... ) as table