Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Lol
I  was attempting an explanation of basic syntax. Now it fast forwards to advanced performance options....
Hi Luke,
Is this resolved? Please advise.