我有一个列!表;例子(Hallo(Deutsch)=你好,Montag(Deutsch)=星期一)
Id, LanguageID, ResourceName, ResourceValue
1 1 Hello Hello
2 2 Hello Hallo
3 1 Monday Monday
4 2 Monday Montag
如何查看此类查询的结果:
ResourceName ResourceValue(languageID=1) ResourceValue(LanguageID=2)
Hello Hello Hallo
Monday Monday Montag
答案 0 :(得分:4)
您可以使用带有CASE
表达式的聚合函数来获取结果:
select ResourceName,
max(case when languageid = 1 then ResourceValue end) Language1,
max(case when languageid = 2 then ResourceValue end) Language2
from yourtable
group by resourcename
如果您有其他LanguageId
值,则可以添加更多案例表达式。
答案 1 :(得分:2)
这可能有用......
select
t1.resourcename,
t1.resourcevalue,
t2.resourcevalue
from
tablename t1,
tablename t2
where
t1.resourcename = t2.resourcename and
t1.languageid = 1 and
t2.languageid = 2