gpt4 book ai didi

MySQL 查询重新排列列和行

转载 作者:行者123 更新时间:2023-11-29 23:19:49 24 4
gpt4 key购买 nike

我有一个表格 View :

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

请就如何构建查询以正确完成查询提供建议。

最佳答案

尝试这样

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

关于MySQL 查询重新排列列和行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27420662/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com