|
-
September 4th, 2009, 10:37 AM
#1
Trouble with Select Distinct() FROM Sub Select
Hi,
I'm using SQL Server 2005 and I'm having a bit of trouble with something that seems like it should be pretty simple.
I have a table with 2 fields - AccountNo and Name. Neither field has to be unique.
I want to get the number of distinct AccountNo where the Name begins with the letter a.
Code:
SELECT DISTINCT(AccountNo) FROM (SELECT AccountNo FROM Customers WHERE Name LIKE 'a%')
The query fails and I get the message "Incorrect syntax near ')".
I'm sure I'm doing something pretty stupid somewhere. Can anyone help me figure out what it it?
Thanks,
dlarkin77
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|