Possible Duplicate:
Subtraction in sql statement
I have a table with Presidents names and I want to count how many (distinct presidents) served for over 4 years.
So I wrote the following query however it doesn’t work. Error is:
Invalid query: You have an error in your SQL syntax, near '*) FROM
(SELECT DISTINCT P1.firstName, P1.lastName FROM Presidents P1 ' at
line 1
Query is:
SELECT COUNT (*)
FROM (SELECT DISTINCT P1.firstName, P1.lastName
FROM Presidents P1
WHERE (P1.endTerm - P1.beginTerm) > 4) M;
Anyone see the syntax error?
thanks!
Just remove the space between
COUNTand(*)or even better rewrite query to: