我是 mysql 新手,编写了一个 My sql 查询并尝试使用两个子查询进行外部连接,但结果未显示准确的结果这里是查询
SELECT a.lpcode,a.lpname,a.companycode,a.zone,a.tdy_growr,a.tdy_acres,b.tdate_growr,tdate_acres,a.name
FROM (SELECT z.lpcode,
x.companycode,
z.lpname,
z.zone,
z.name,
count(x.vehicleno) tdy_growr,
sum(x.haulagecode) tdy_acres
FROM gis.registration x, loadingpoint z
WHERE x.date =
(SELECT max(a.date)
FROM gis.registration a
WHERE a.fieldno > 0
AND a.haulagecode > 0
AND a.isaccepted = 1)
AND z.lpcode = x.lpcode
AND x.fieldno > 0
AND x.haulagecode > 0
AND x.isaccepted = 1
GROUP BY x.lpcode) a
RIGHT OUTER JOIN
(SELECT r.lpcode,
count(r.vehicleno) tdate_growr,
sum(r.haulagecode) tdate_acres
FROM gis.registration r, loadingpoint l
WHERE r.fieldno > 0 AND r.haulagecode > 0 AND r.isaccepted = 1
AND r.lpcode = l.lpcode
GROUP BY l.lpcode) b
ON a.lpcode = b.lpcode
ORDER BY a.zone, a.lpcode
任何帮助都可以提前感谢