【发布时间】:2020-09-22 23:20:55
【问题描述】:
【问题讨论】:
-
我所尝试的只是'从 COALESCE(columnd, columnE) 不为空的表中选择 *
标签: sql sql-server string group-by sql-null
【问题讨论】:
标签: sql sql-server string group-by sql-null
如果要合并前三列中具有相同值的行,则使用聚合:
select columna, columnb,columnc, max(columnd) columnd, max(columne) columne
from mytable
group by columna, columnb, columnc
聚合函数 - 例如 max() - 忽略 null 值,因此 max(columnd) 在具有相同 (columna, columnb,columnc) 的行中为您提供非 null 值。
【讨论】:
select 子句中不在聚合函数中的所有列(此处为 max())必须在 group by 子句中重复。