I look at access logs for specific courses. I need to show all courses, even if they do not exist in the log table. Therefore, the outer join ... but after trying (presumably) all the changes to LEFT OUTER , RIGHT OUTER , INNER and placing the tables in the SQL code, I could not get my result.
Here is what I run:
SELECT (a.first_name+' '+a.last_name) instructor, c.course_id, COUNT(l.access_date) course_logins, a.logins system_logins, MAX(l.access_date) last_course_login, a.last_login last_system_login FROM lsn_logs l RIGHT OUTER JOIN courses c ON l.course_id = c.course_id, accounts a WHERE l.object_id = 'LOGIN' AND c.course_type = 'COURSE' AND c.course_id NOT LIKE '%TEST%' AND a.account_rights > 2 AND l.user_id = a.username AND ((a.first_name+' '+a.last_name) = c.instructor) GROUP BY c.course_id, a.first_name, a.last_name, a.last_login, a.logins, c.instructor ORDER BY a.last_name, a.first_name, c.course_id, course_logins DESC
Is this something in the WHERE that prevents me from getting the course_id, which is not in lsn_logs? So am I joining the tables?
In short, I want all of the course_id to be independent of their existence in lsn_logs.
sql inner-join outer-join sql-server-2005
CheeseConQueso
source share