Reputation: 3
Here is my code.
SELECT BUSEO, SUBSTR(SSN,8,1)
FROM TBLINSA
GROUP BY BUSEO, SUBSTR(SSN,8,1)
HAVING (SUBSTR(SSN,8,1) = 2) >= 5;
What I intended was the condition that substr(ssn,8,1)
must have a value of 2 and
substr(ssn, 8, 1)=2
greater than 5.
But the result produced an SQL command not properly ended error.
I am wondering how I can fix this.
Upvotes: 0
Views: 44
Reputation: 521093
I think you want the substring restriction in a WHERE
clause. Then aggregate by BUSEO
and assert a count greater than or equal to 5.
SELECT BUSEO
FROM TBLINSA
WHERE SUBSTR(SSN, 8, 1) = '2'
GROUP BY BUSEO
HAVING COUNT(*) >= 5;
Upvotes: 3