I'm having some trouble with a query. I'm supposed to pull up all the client info where the client has only taken 1 test and passed. I was told to use the IN operator. This is what I have:
SELECT *
FROM Client
WHERE ClientName IN (SELECT ClientName, COUNT(TestNbr)
FROM Test
GROUP BY ClientName, TestResult
HAVING COUNT(TestNbr)=1
AND TestResult='Pass');
I get this error:
(SELECT ClientName, COUNT(TestNbr)
*
ERROR at line 4:
ORA-00913: too many values
I understand that it's because I shouldn't have any other entry except for ClientName in that line. How can I fix this problem?
remove the
COUNT(*)column on the subquery as it is not neccesary on the result,but I'd rather use
JOINinstead of usingINfor faster performance, add an index on column
ClientNameon both tables.