在SQL Server中,是否有机会显示3个表的结果? (实际上是4)
第4个表包含1个与其他列相似的列。其他3个表的类似列的值是不同的。换句话说,如果在第4个表格列中选择“1”,则应显示第1个表格的结果,如果选择“2”,则显示第2个等...
答案 0 :(得分: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