Link to home
Start Free TrialLog in
Avatar of stuart_wachsberg
stuart_wachsberg

asked on

syntax error for subselect

I am running  sql server desktop edition (MSDE 2000).

I need a count of a union:

select count (*) from ( select id from member union select id from dropoffpoint  )

Running the above in the Query analyzer SQL Server yields this error:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ')'.

Even a simplified version:
select * from (select id from member)
yields the same error.

Can anyone pls try something similar on MSDE? On the fullblown SQL Server?
Any help appreciated....I do not wish to resort to a temp table because it should be unnecessary here.
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Hi stuart_wachsberg,

In Access VBA, you can't count off of the asterisk *, you have to Count(one of your fields).  Perhaps SQL Server SQL is the same.

Hope this helps.
-Jim
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>select * from (select id from member)<<
Same story here, you need to alias your FROM as in :
select * from (select id from member) a

Avatar of stuart_wachsberg
stuart_wachsberg

ASKER

how did u know, acperkins? Is this unique to sql server? I have never seeen this before.

Thanks for the quick and helpful response.
>>how did u know, acperkins?<<
I think I learned that here <g>
its rather odd, but u rescued me. thanks again and Happy Holiday.