请您帮我弄清楚如何为我在表上添加的每个idLanguage创建一个临时计算字段(customDescription2,customDescription3…)。下表中显示的数据来自1表。
答案 0 :(得分:1)
如果您知道语言ID,则可以使用条件聚合:
select substitute, barcode,
max(case when idlanguage = 1 then customDescription end) as customDescription1,
max(case when idlanguage = 2 then customDescription end) as customDescription2,
max(case when idlanguage = 3 then customDescription end) as customDescription3,
max(case when idlanguage = 4 then customDescription end) as customDescription4
from t
group by substitute, barcode;