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
问问题
59 次
2 回答
3
尝试这个:
SELECT
user_Id, MAX(colA) colA, MAX(colB) colB
FROM tbl
GROUP BY user_Id
于 2013-02-18T17:28:13.157 回答
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
于 2013-02-18T17:59:28.557 回答