0

SQL Server で、3 つのテーブルの結果を表示する機会はありますか? (実際は 4)

4 番目のテーブルには、他と同様の 1 つの列が含まれています。他の 3 つのテーブルの同様の列の値は異なります。つまり、4 番目のテーブル列で「1」を選択すると、1 番目のテーブルの結果が表示され、「2」を選択すると 2 番目の結果が表示されます。

4

1 に答える 1

0
select fourth.pk,
case fourth.columnx
when '1' then one.columnx
when '2' then two.columnx
when '3' then three.columnx
else 'Exception to the rule?' 
end as 'Column A'
from fourth 
join one on fourth.joinid=one.joinid
join two on fourth.joinid=two.joinid
join three on fourth.joinid=three.joinid
于 2013-03-18T18:34:14.747 に答える