我有这种桌子:
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-10-01T17:38:22.425+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-10-01T17:38:22.426+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed
我想消除空值。我希望它像这样:
Column 1 | Column 2 | Column 3 | Column 4
----------------------------------------
Value 1 | null | null | null
null | Value 2 | null | null
null | null | Value 3 | null
null | null | null | Value 4
任何帮助将不胜感激。谢谢。
答案 0 :(得分:3)
似乎您要聚合:
select max(col1), max(col2), max(col3), max(col4)
from table t;
假设您有支持的专栏,那么您可以:
select col, max(col1), max(col2), max(col3), max(col4)
from table t
group by col;