MySQL Forums
Forum List  »  Newbie

Re: Multiple Tables, COUNT query
Posted by: Jay Pipes
Date: August 11, 2005 07:49PM

Coming from Access and Excel? :)

Try this:

SELECT
a.idnApplicationsID
, SUM(IF(d.intAppDocType=1,1,0)) AS CV
, SUM(IF(d.intAppDocType=2,1,0)) AS TR
, SUM(IF(d.intAppDocType=3,1,0)) AS PU
, SUM(IF(d.intAppDocType=4,1,0)) AS RP
, COUNT(r.idnReferenceID) AS RL
FROM tblApplications a
LEFT JOIN tblAppDocuments d
ON a.intApplicationID = d.intApplicationID
LEFT JOIN tblAppReferences r
ON a.intApplicationID = r.intApplicationID;

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Written By
Posted
Re: Multiple Tables, COUNT query
August 11, 2005 07:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.