Home > database >  Oracle 11 g
Oracle 11 g

Time:10-01

I now have two tables A and B, with all the data in A, B is only part of the data, and then I use A dictionary in the minus B in the fields, when B is empty, minus 0, but I wrote this, check out results is empty, what A great god help me to look at how to write
The select Amy polumbo luid, a.c kcode,
The sum ((A.K cCount - (case when B.X sCount is null then 0 else B.X sCount end))) as kc
The from tStkLsKc A, tSalWtzPluDetail b
Where Amy polumbo luid=p. luid and Amy polumbo luid='10000000772' and b.D ataType in (' 0 ', 'A', 'B', 'C', '7')
Group by Amy polumbo luid, a.c kcode

CodePudding user response:

The building Lord give some sample data, and your desired results,

CodePudding user response:

 select Amy polumbo luid, a.c kcode, 
The sum (A.K cCount - NVL (B.X sCount, 0)) as kc
The from tStkLsKc A, tSalWtzPluDetail b
Where Amy polumbo luid=p. luid and Amy polumbo luid='10000000772' and b.D ataType in (' 0 ', 'A', 'B', 'C', '7')
Group by Amy polumbo luid, a.c kcode
using the NVL function, than you had the better readability, as to what you said is empty, that is data problems, did not meet the conditions of the data

CodePudding user response:

The original poster to express the meaning of the vague
Is A table to match the data in the table B B table does not correspond to record XsCount as 0, or recorded in the corresponding table B XsCount value is NULL, XsCount as 0
The former needs associated with the latter NVL can

CodePudding user response:

The
reference 3 floor dd215130268 response:
express the meaning of the building Lord compares fuzzy
Is A table to match the data in the table B B table does not correspond to record XsCount as 0, or recorded in the corresponding table B XsCount value is NULL, XsCount as 0
The former needs associated with the latter NVL can

3/f positive solutions

CodePudding user response:

reference 4 floor zxying2012 response:
Quote: reference dd215130268 reply: 3/f

The original poster to express the meaning of the vague
Is A table to match the data in the table B B table does not correspond to record XsCount as 0, or recorded in the corresponding table B XsCount value is NULL, XsCount as 0
The former needs associated with the latter NVL can

3/f positive solution
adversary, with external connection, see the along while didn't see that way way, it points out the true meaning