我有一个场景,其中检索我的数据如下所示
产品计量单位数量
汽油桶13000桶
汽油MT 20000
柴油桶7500桶
柴油MT 2500
我需要不同输出中的输出,如下所示
产品桶MT
汽油13000 20000
柴油7500 2500
请帮助我形成这个查询,我已经尝试了很长一段时间,但没有成功的结果。
发布于 2014-05-15 21:56:01
听起来像是你在尝试PIVOT你的结果。假设您知道列数,一种选择是结合使用MAX和CASE
select product,
max(case when uom = 'Barrels' then quantity end) BarrelsQty,
max(case when uom = 'MT' then quantity end) MTQty
from yourtable
group by producthttps://stackoverflow.com/questions/23680285
复制相似问题