我有一个问题,关于那我就无法检索到正确的结果
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