July 22, 2010

left outer join more than 3 table

SELECT a.supply, a.state, b.cost
FROM (Table1 a LEFT OUTER JOIN Table2 b ON a.supply = b.supply AND a.state = b.state) 
LEFT OUTER JOIN Table3 c ON a.supply = c.supply
GROUP BY a.supply, a.state, b.cost, c.number, c.number2

No comments: