Wednesday, June 8, 2011

Left Join - Another way

In the previous post, I used the LEFT JOIN (SELECT * from file) filename on filename.key=other.key to do a left join on tables not specified in the FROM Clause.

Here is another way to accomplish it. I don't know how it works but it does and I will dissect it until I understand it, maybe<G>.

SELECT batchcontract.certificate,
ClaimTotal.SumOfCheckAmount,
batchheader.uniquekey,
  Dealer.State
  AS DealerState
  FROM
(
(BatchHeader  LEFT JOIN Dealer ON  BatchHeader.Dealer = Dealer.uniquekey)
   LEFT JOIN  BatchContract ON BatchHeader.uniquekey =  BatchContract.BatchNum
)

LEFT JOIN ClaimTotal ON  BatchContract.uniquekey = ClaimTotal.iWarranty

WHERE iWarranty= 24492;

No comments:

Post a Comment