有一个包含列category not null
、sub_category default null
的表.
-
category
始终设置 -
sub_category
是可选的
我需要从表中 Select distinct category,sub_category
个,
- 排除sub_category不为null且为null的记录
- 如果只有
category
+<null>
的一个组合,请保留记录
category sub_category
girl_toys fluffy
girl_toys dolls
drawing <null> -- keep it since only one null sub_category
paining red_color
paining <null> -- exclude since there is non null sub_category
预期结果:
category sub_category
girl_toys fluffy
girl_toys dolls
drawing <null> -- keep is since drawing has only one null
paining red_color -- <null> record excluded since there is non null sub_category exists