我有一個問題,關於那我就無法檢索到正確的結果
SELECT distinct companyid,
companyshortname,
loanamount,
employeename,
, employeerole,
MaxTime,
businessdescription
FROM company
INNER JOIN loan ON companyfkey = loanfkey
LEFT JOIN (SELECT businessdescription_fkey,
MAX(w.business_date_transaction_occured) AS MaxTime
FROM businessdescription w
WHERE w.businessstatus <> 3 <-- this means that the company is still open
GROUP BY w.businessdescription_fkey) wf
ON company_fkey = businessdescriotion_fkey
工作這回我有一個狀態比3個不同的所有企業一個SQL腳本,但我的第一個問題是它返回給我的所有業務,確實有狀態3.
我的第二個問題是我將如何納入另一個值來跟蹤如Businessdescriptioncomment我會做這樣的事情?
LEFT JOIN (SELECT businessdescription_fkey,
MAX(w.business_date_transaction_occured) AS MaxTime ,
w.businessdescriptioncomment AS BusinessComment
FROM businessdescription w
WHERE w.businessstatus <> 3 <-- this means that the company is open
GROUP BY w.businessdescription_fkey) wf
ON company_fkey = businessdescriotion_fkey
和我的變量BusinessComment到我的第一個選擇?
感謝您的任何幫助。
您是否檢查過內部選擇? 它只是返回business = 3的行嗎? 如果是這樣,也許更改左加入INNER加入 –
有一個雙','這裏:'employeename,,employeerole,' – McNets
你的問題是不清楚..你有錯誤嗎? ...錯誤的結果...? .. – scaisEdge