0
在SQL Server 2005中,通過在兩列上連接兩個表,我們如何通過將第一個表的兩列匹配到第二個表的兩列來獲取值,匹配列?SQL Server 2005--連接兩個表和兩列
以下是在示例表:
表1:
City Vehicle Count
---------------------------
London Two wheeler 834
NewYork Four wheeler 60
NewYork Two wheeler 3
Sydney Four wheeler 514
Sydney Two wheeler 4551
表2:
City Vehicle Count
---------------------------
London Two wheeler 5
NewYork Two wheeler 2
Sydney Two wheeler 16
預期的輸出:
City Vehicle Count
---------------------------
London Two wheeler 5
NewYork Four wheeler 0
NewYork Two wheeler 2
Sydney Four wheeler 0
Sydney Two wheeler 16
我這樣做成功上使用Pivot的MS Excel表公式:
{=INDEX($L$6:$L$550,MATCH(F6,IF($K$6:$K$550=G6,$J$6:$J$550),0))}
你問如何寫一個'SELECT'聲明?你有沒有嘗試過或要求提供代碼? –