当我运行这个SQL时,我遇到了麻烦:
Create Table test_temp (
gsid Number,
sl Number);
Insert Into test_temp Values(53010100,15);
Insert Into test_temp Values(53010000,10);
Insert Into test_temp Values(53000000,5);
Select * From (
Select Sum(sl), gsid, substr(gsid, 0, 4) sj_gsid, substr(gsid, 0, 2) pro_gsid
From test_temp
Group By Rollup(substr(gsid, 0, 2), substr(gsid, 0, 4), gsid))
Where sj_gsid <>'5300'在Oracle11g R2 (Linux)上。
我想还会有5行。如下所示:

但是,最后,我得到了3行返回:

怎么一回事?
发布于 2016-04-14 04:08:40
您只返回三行,因为您丢失的两行对于sj_gsid是空的。您确实了解空<> '5300‘不是真,而是未知,并且只返回条件为真的行,对吗?如果希望将它们包括在内,则必须将or sj_gsid is null添加到where条件中。
https://stackoverflow.com/questions/36613455
复制相似问题