Select ID, Yes from (
SELECT ID, 'Col1' as 'Yes' where Col1 = 'yes'
UNION ALL
SELECT ID, 'Col2' as 'Yes' where Col2 = 'yes'
UNION ALL
SELECT ID, 'Col3' as 'Yes' where Col3 = 'yes'
UNION ALL
SELECT ID, 'Col4' as 'Yes' where Col4 = 'yes'
UNION ALL
SELECT ID, NULL as 'Yes' where Col1 != 'yes' and Col2 != 'yes' and Col3 != 'yes' and Col4 != 'yes'
) TempTable ORDER BY ID
2条答案
按热度按时间2ekbmq321#
你可以试试这个
toiithl62#
你可以用
conditional_emit
来自砖厂的自定义项(http://github.com/klout/brickhouse )做这个。