MySQL 选择标题和列

问题描述 投票:0回答:1

我有这个输出:

SELECT Arquivo, Safra, LinhasA FROM t411 LIMIT 10;

enter image description here

我想得到这样的输出:

enter image description here

有没有办法直接使用SELECT?

...如有必要,也可以通过PROCEDURE。

如果有人能提供帮助,我将非常感激。 我使用 MySQL Server(最新版本)并通过 MySQL Workbench 运行我的选择

sql mysql select stored-procedures workbench
1个回答
0
投票

我不明白你为什么使用 limit 10 但是,你能试试这个吗?

select
Arquivo,
max(case when Safra = '2019/2020' then LinhasA else 0 end) as '2019/2020',
max(case when Safra = '2020/2021' then LinhasA else 0 end) as '2020/2021',
max(case when Safra = '2021/2022' then LinhasA ELSE 0 end) as '2021/2022'
from t411
group by 1;
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.