Advertisement

03.18.2008 at 02:58PM PDT, ID: 23251938
[x]
Attachment Details

Left Outer Join with Count, showing 1 when should be zero

Asked by Valimai in SQL Query Syntax, SQL Server 2005

Hello,

I have the following query where a course has a course licensing profile where there are users utilizing licenses.

When there is a course record and a course licensing record, but no user licenses used; the query i have reports a usercount of 1. How can i get it to display a count of zero?

SELECT     tblCourseLicensing.CourseLicensingID, tblCourse.Name, COUNT(*) AS UserCount
FROM         tblCourseLicensing INNER JOIN
                      tblCourse ON tblCourseLicensing.CourseID = tblCourse.CourseID LEFT OUTER JOIN
                      tblCourseLicensingUser ON tblCourseLicensing.CourseLicensingID = tblCourseLicensingUser.CourseLicensingID
GROUP BY tblCourseLicensing.CourseLicensingID, tblCourse.Name
HAVING      (tblCourseLicensing.CourseLicensingID = 1)Start Free Trial
[+][-]03.18.2008 at 03:59PM PDT, ID: 21157010

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.18.2008 at 04:00PM PDT, ID: 21157018

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, SQL Server 2005
Sign Up Now!
Solution Provided By: frankytee
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.18.2008 at 04:16PM PDT, ID: 21157118

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628