my table is:
id val catid
1 title1 7
2 text1 8
3 title2 7
4 text2 8
I want combine rows as this:
val1 val2
title1 text1
title2 text2
I used this query:
select
(case when catid = 7 then val end) val1,
(case when catid = 8 then val end) val2
from mytable
But my result is:
val1 val2
title1 Null
Null text1
title1 Null
Null text2
How to fix it? Thanks
Aucun commentaire:
Enregistrer un commentaire