0
我需要查詢SQL Server中的數據集,並根據兩個子查詢中的任意一個查詢返回列。哪個子查詢的控制來自查詢中另一列的值。一些基本的僞查詢語言,我想做什麼:SQL Server中的條件連接
select col1, col2, col3,
if col3 = 1
(select count(*) from table2 where table2.col1 = table1.col1) as count1
else
(select count(*) from table3 where table3.col1 = table1.col1) as count1
from table1
什麼是最好的方法來實現這一目標?
太棒了。謝謝 – user2391532