我在SQL Server中有兩個表,Table1
和Table2
。兩個表都有一列EmployeeName
,它應該幾乎匹配兩個表。如何比較SQL Server中的兩個表爲匹配的員工添加值
這是在表1中我的樣本數據:
EmployeeName Expenses Bonus overTime
-----------------------------------------
John 198 3734 230
Ayesa 0 2384 0
Nimi 400 230 0
Michael 0 571 0
Alexander 212 240 0
表2 Employee Name
幾乎具有相同的值 - 這樣的:
EmployeeName Ermatch Roth
-----------------------------------
John 298 500
Ayesa 0 450
Nimi 400 250
Michael 0 551
現在兩個表其是僱員匹配兩者Table 1
和Table 2
。最後加入一個表像這樣
EmployeeName Expenses Bonus overTime Ermatch Roth
----------------------------------------------------------
John 198 3734 230 298 500
Ayesa 0 2384 0 0 450
Nimi 958 230 0 400 250
Michael 0 571 0 0 551
Alexander 212 240 0 0 0
哪些是Employeename兩個表Ermatch和羅斯加入表1.如何加入兩個表的匹配嗎?如何比較兩個表僱傭。在此先感謝
刪除不兼容'mysql'標籤 – Jens
好,謝謝,先生@Jens – sripriya
嘗試使用不同的?這是參考。 http://stackoverflow.com/questions/17931256/mysql-select-distinct-values-from-two-table-that-have-a-common-key –