mercredi 3 février 2016

SQL syntax error or missing database (near "(": syntax error) when using union

I am trying to use union but i get this vague syntax error. I Can get each query to run seperately, but when i try to use union i get this error.

(SELECT s.sname, COUNT(s.sname) AS number
FROM sailor s, boat b
WHERE  b.rating <= s.rating
GROUP BY s.sname)
UNION
(SELECT s.sname, 0 AS number
FROM sailor s
WHERE NOT EXISTS(
              SELECT * FROM boat b
              WHERE s.rating >= b.rating));

Aucun commentaire:

Enregistrer un commentaire