我有3個表:的Sql內加入不同值
- 銀行轉賬
- 受益人
- Callback_Procedure
我也來加入與內這3個表連接。
在銀行轉賬中,我有一列Number
,在受益人和回撥表中重複了Number
。
在Beneficiaries
表中,該數字可以重複多次。
當運行我的內部連接查詢時,獲取多於1個結果而不是獲取唯一值。
在Beneficiaries
表中,我也有一個列Beneficial_Name
,它是唯一標識結果的列,但是在運行連接查詢時,會得到重複的結果。
我已經嘗試了不同的選項,而不是很好的結果。
下面是我的代碼 - 有人可以幫我嗎?
SELECT DISTINCT
dbo.BT_Beneficiaries.Beneficial_Name,
dbo.Bank_Transfer.Number, dbo.Bank_Transfer.Start_Date,
dbo.Bank_Transfer.Team_Name, dbo.Bank_Transfer.Initiator,
dbo.Bank_Transfer.Staff, dbo.Bank_Transfer.Process_Name,
dbo.Bank_Transfer.Company_Name, dbo.Bank_Transfer.Billing_Amount,
dbo.Bank_Transfer.Entry_ID, dbo.Bank_Transfer.Instructions,
dbo.Bank_Transfer.BT_Count, dbo.Bank_Transfer.Misspelled,
dbo.Bank_Transfer.Sender, dbo.Bank_Transfer.Odd,
dbo.Bank_Transfer.Email, dbo.Bank_Transfer.Beneficiary,
dbo.Bank_Transfer.Address, dbo.Bank_Transfer.Urgent,
dbo.Bank_Transfer.Payment, dbo.Bank_Transfer.Sperry,
dbo.Bank_Transfer.Contact, dbo.Bank_Transfer.Reasonable,
dbo.Bank_Transfer.Evidence_Completed, dbo.Bank_Transfer.End_Date,
dbo.Bank_Transfer.First_Mgr_Approval_Name, dbo.Bank_Transfer.First_Mgr_Approval,
dbo.Bank_Transfer.First_Mgr_Approval_Date, dbo.Bank_Transfer.CallBack_Workings,
dbo.Bank_Transfer.CallBack_Agreement, dbo.Bank_Transfer.CallBack_Procedure,
dbo.Bank_Transfer.Second_Mgr_Approval_Name, dbo.Bank_Transfer.Second_Mgr_Approval,
dbo.Bank_Transfer.Second_Mgr_Approval_Date, dbo.Bank_Transfer.IB,
dbo.Bank_Transfer.IB_Date, dbo.Bank_Transfer.ITL_Signatory_Approval,
dbo.Bank_Transfer.ITL_Signatory_Name,
dbo.BT_Beneficiaries.Account_Number, dbo.BT_Beneficiaries.Currency,
dbo.BT_Beneficiaries.Payment_Details, dbo.BT_Beneficiaries.CurrencyPayment,
dbo.BT_Beneficiaries.Amount, dbo.BT_Beneficiaries.Purpose,
dbo.BT_Beneficiaries.Evidence, dbo.BT_Beneficiaries.Due_Diligence,
dbo.BT_Beneficiaries.WC, dbo.BT_Beneficiaries.Resolution_Directors,
dbo.BT_Beneficiaries.Manager_Approval, dbo.BT_Beneficiaries.Mgr_Approval_Date,
dbo.CB_BankAccount.Number AS Expr3, dbo.CB_BankAccount.Company_Name AS Expr4,
dbo.CB_BankAccount.Bank_Name, dbo.CB_BankAccount.Bank_Account,
dbo.CB_BankAccount.Currency AS Expr5, dbo.CB_BankAccount.Balance,
dbo.CB_BankAccount.Bank_Mandate, dbo.CB_BankAccount.Signing_Arrangement AS Expr6,
dbo.CB_CallBack_Procedure.Number AS Expr8, dbo.CB_CallBack_Procedure.CallStatus,
dbo.CB_CallBack_Procedure.Person_CalledBack, dbo.CB_CallBack_Procedure.DateTime,
dbo.CB_CallBack_Procedure.Notes, dbo.CB_CallBack_Procedure.Mgr_Approval,
dbo.CB_CallBack_Procedure.DateTime_Approval, dbo.CB_CallBack_Procedure.Bank_DateTime
FROM
dbo.Bank_Transfer
INNER JOIN
dbo.BT_Beneficiaries ON dbo.Bank_Transfer.Number = dbo.BT_Beneficiaries.Number
INNER JOIN
dbo.CB_BankAccount ON dbo.BT_Beneficiaries.Number = dbo.CB_BankAccount.BT_Number
INNER JOIN
dbo.CB_CallBack_Procedure ON dbo.CB_BankAccount.BT_Number = dbo.CB_CallBack_Procedure.Number
在受益名稱欄中需要說明什麼才能知道該記錄是您想要的記錄? – kbball