I have data like
user Id colA colB
12 abc NULL
13 123 NULL
13 NULL 567
I want output like
user Id colA colB
12 abc NULL
13 123 567
答案 0 :(得分:3)
试试这个:
SELECT
user_Id, MAX(colA) colA, MAX(colB) colB
FROM tbl
GROUP BY user_Id
答案 1 :(得分:0)
试试这个
select user_id ,
if (colA = NULL , 0 , max(colA)) colA ,
if (colB = NULL, 0 , max(colB)) colB
from a
group by user_id
输出将是:
USER_ID COLA COLB
12 abc (null)
13 123 567