标题: LEFT JION的用法 [打印本页] 作者: yuanzai32 时间: 2011-11-22 15:11 标题: LEFT JION的用法 SELECT IFNULL(SUM(skt43.skf610),0)-IFNULL(SUM(skt43.skf669),0),
skt57.skf772
FROM skt57
LEFT JOIN (skt43,skt42)
ON (skt43.skf616=skt42.skf587
AND skt57.skf772=skt42.skf589
AND skt42.skf591=5
AND skt43.skf611>=20110701
AND skt43.skf611<=20110930)
AND skt42.skf597=0
GROUP BY skt57.skf772,skt42.skf590
HAVING skt42.skf590=16;
SELECT IFNULL(SUM(skt43.skf610),0)-IFNULL(SUM(skt43.skf669),0),
skt57.skf772,
FROM skt43,skt42,skt57
WHERE skt43.skf616=skt42.skf587
AND skt57.skf772=skt42.skf589
AND skt42.skf590=16
AND skt42.skf591=5 AND SKT42.SKF597=0
AND skt43.skf611>=20110701
AND skt43.skf611<=20110930
GROUP BY skt57.skf772;