Rashmika Lakshan
Rashmika Lakshan

Reputation: 11

How to fix this SQL syntax error in mysql

This SQL command:

SELECT pno,COUNT (DISTINCT sno) AS supplier_count
FROM spj
GROUP BY pno;

gives me below error:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT sno) AS supplier_count FROM spj GROUP BY pno' at line 1

How to fix this error?

Upvotes: 0

Views: 106

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269793

Remove the space between the COUNT and ():

SELECT pno, COUNT(DISTINCT sno) AS supplier_count
FROM spj
GROUP BY pno;

Upvotes: 2

Related Questions