Home > database >  Merge two table query results
Merge two table query results

Time:09-26

Two tables a normal consumption table a member table to date for two tables in total consumption at the same time if there is a date in the table has data in another table did not how to solve

CodePudding user response:

Make a judgment, not counted as zero, a value calculated together

CodePudding user response:

Suggested the building list table structure, and provide the test data, and based on these test data that corresponds to the correct result,
Refer to the way the post questions http://bbs.csdn.net/topics/320211382
So people who want to help you to build the same environment with you directly, and in providing the test before, avoid the error in the text understanding,

CodePudding user response:

SELECT
(SELECT SUM (t1) amount) FROM ordinary consumption table t1 WHERE t1. The consumption date=?) +
(SELECT SUM (t2) amount) FROM member consumption table t2 WHERE t2. The consumption date=?) The FROM DUAL;
  • Related