我有一个表格视图:
company_name Status Status_Created_Date
-------------------------------------------
Company A StatusA 15/11/2014
Company A StatusB 22/11/2014
Company B StatusA 12/11/2014
Company B StatusB 02/11/2014
我希望得到这样的结果:
company_name StatusA StatusB
-------------------------------------------
Company A 15/11/2014
Company A 22/11/2014
Company B 12/11/2014
Company B 02/11/2014
请告诉我如何构建查询以正确完成查询。
答案 0 :(得分:0)
试试这个
select company_name,case when status='statusA' then Status_Created_Date
else '' end "Status A",case when status='statusB' then Status_Created_Date
else '' end "Status B" from table1