FIELD1 FIELD2 FIELD3 FIELD4 FIELD5
A 1 C 1 D1
B2 C2
C3
每个字段都可能为空 取得 一条记录中第一个非空的字段。
------解决方案--------------------
- SQL code
create table tb(col1 int,col2 int,col3 int)insert into tbselect null,null,1 union allselect null,2,1goselect coalesce(col1,col2,col3) colfrom tbdrop table tb/************************col-----------12(2 行受影响)