所以,我有我的PROC的這一部分:需要一些SQL存儲過程的幫助 - 加盟
SELECT
com_contact.rc_name_full as CreatedBy,
capComponent.cm_strike as CapStrike,
floorComponent.cm_strike as FloorStrike,
tq_nominal_notional as Notional,
maxComponent.cm_effective_dt as EffectiveDate,
maxComponent.cm_maturity_dt as MaturityDate,
CAST(CAST(DATEDIFF(mm,maxComponent.cm_effective_dt,maxComponent.cm_maturity_dt) as decimal(9,2))/12 as decimal(9,2)) as term,
(
CASE WHEN se_amort_term_mnth IS NOT NULL THEN se_amort_term_mnth/12
ELSE CAST(CAST(DATEDIFF(mm,
ISNULL(cmam_amortization_start_dt, maxComponent.cm_effective_dt),
cmam_amortization_end_dt) as decimal(9,2))/12 as decimal(9,2))
END
) AS AmortTermYears,
tq_dd_product as Product,
dh_key_rate as KeyRate,
dh_pv01 as PV01,
dh_val_time_stamp as RateTimeStamp,
re_bnk_le.re_company_name as Company,
rc_contact_id as UserId,
stp_name as NickName,
'' as project,
'' as Borrower,
'' as Lender,
'' as AdditionalInfo,
CASE WHEN tpm_pd_permission_id = 85 THEN 'LLH' WHEN tpm_pd_permission_id = 86 THEN 'ALM' ELSE '' END as Permission,
tr_transaction_id as TransactionId,
NULL as IndicationId
FROM cfo_transaction
,說'' as project
行,我們必須真正改變現在返回的數據。
FROM
旁邊的表格,名爲cfo_transaction
上有一個名爲tr_transaction_id
的ID。我們有一個叫做com_project_transaction_link
另一個表,鏈接這些ID與項目的ID,用兩個兩列名爲:
pt_tr_transaction_id
和pt_pj_project_id
,然後我們有一個包含具有pj_project_id
和pj_project_name
稱爲com_project
所有項目的表格。
目標:從該項目表中返回pj_project_name
,在該項目表中鏈接正在被拉的事務。
我真的不知道該怎麼做。
謝謝!