SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Zero count
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nigelc
Starting Member

United Kingdom
20 Posts

Posted - 12/11/2006 :  07:06:22  Show Profile  Reply with Quote
I have a query that counts the number of training modules a user has sat. This works fine but I want it to be able to list the names aof all users who have not yet sat a course. Query I am using is:

SELECT pps_principals.name AS principals_name,
COUNT(*) AS coursecount
FROM (PPS_SCOS JOIN PPS_TRANSCRIPTS ON PPS_SCOS.SCO_ID = PPS_TRANSCRIPTS.SCO_ID)
JOIN PPS_PRINCIPALS ON PPS_TRANSCRIPTS.PRINCIPAL_ID = PPS_PRINCIPALS.PRINCIPAL_ID
AND PPS_TRANSCRIPTS.TICKET not like 'l-%'
and pps_scos.name like 'MT%'
GROUP BY pps_principals.name
HAVING COUNT(*) = 0

The principals.name is the user name. Scos.name being the course name. This query returns no rows at all.

harsh_athalye
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 12/11/2006 :  07:15:31  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
SELECT
	pps_principals.name AS principals_name
FROM 
	PPS_PRINCIPALS join PPS_TRANSCRIPTS on PPS_TRANSCRIPTS.PRINCIPAL_ID = PPS_PRINCIPALS.PRINCIPAL_ID
	Left Join PPS_SCOS on PPS_SCOS.SCO_ID = PPS_TRANSCRIPTS.SCO_ID
Where
	PPS_SCOS.SCO_ID is NULL and
	AND PPS_TRANSCRIPTS.TICKET not like 'l-%'
	and pps_scos.name like 'MT%'


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

nigelc
Starting Member

United Kingdom
20 Posts

Posted - 12/11/2006 :  07:20:24  Show Profile  Reply with Quote
I have tried this but it still comes back with no names.

Thanks
Go to Top of Page

harsh_athalye
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 12/11/2006 :  07:22:13  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
It would be helpful if you could post table structures and their relationships.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 12/11/2006 :  07:45:09  Show Profile  Visit SwePeso's Homepage  Reply with Quote
He almost did here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76088


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000