Link to home
Create AccountLog in
Avatar of Luke Pope
Luke Pope

asked on

SQL Code help

Here is question. Here is SQL Im not getting it right.

SELECT a.AdvisorID, a.LastName, a.FirstName, COUNT( s.StudentID ) AS "COUNT(Students)"
FROM Advisors a
JOIN Students s
ON a.AdvisorID = s.AdvisorID
GROUP BY a.AdvisorID
HAVING COUNT(s.StudentID)='1';
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Try
SELECT a.AdvisorID, a.LastName, a.FirstName, COUNT( s.StudentID ) AS "COUNT(Students)"
FROM Advisors a
JOIN Students s
ON a.AdvisorID = s.AdvisorID
GROUP BY a.AdvisorID, a.LastName, a.FirstName
HAVING COUNT(s.StudentID)>=1;

Open in new window

SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
@HuaMinChen

Why did you change the original query to >= 1 ?? There is no apparent reason to do this
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Lol
I  was attempting an explanation of basic syntax. Now it fast forwards to advanced performance options....
Hi Luke,
Is this resolved? Please advise.