Sam Carter scforum at iness.com
Mon Feb 2 12:11:46 CST 2004

HAVING is similar to WHERE but applies to GROUP BY

SELECT Company, Products,  count(*) as Total
from MyTable
WHERE Company BETWEEN 'a' AND 'm'
GROUP BY Company, Products
HAVING count(*) > 10

I think you mean LEFT OUTER JOIN -- this means keep all the rows on the
left, and if there's no join on the right, add NULL column values

SELECT  C.Companyname, CASE WHERE A.Agencyname IS NULL THEN 'No Agency
Found' ELSE A.Agencyname END As Agencyname
>From MyCompanies C
LEFT OUTER JOIN MyAgencies A ON C.Companyname = A.Customername

-- This query will list all Companies where there is no Agency .  There's a
lot you can do with LEFT OUTER.

Visit the forums on sqlteam.com 

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Chris Marsh
Sent: Monday, February 02, 2004 12:52 PM
To: thelist at lists.evolt.org
Subject: [thelist] SQL - HAVING and OUTER LEFT JOIN

Dear all

With regards to SQL, can someone explain to me in simple terms what the 
HAVING clause does, and what an OUTER LEFT JOIN does?

I have found several tutorial sites, but am still having problems grasping 
what exactly the aborementioned do.

Many thanks in advance.


Chris Marsh
* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 

More information about the thelist mailing list