Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Invalid column name
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00368854
Message ID:
00369139
Views:
13
>I'm trying to count how many customers we have per 1st letter of point of contact (POC). I'm using:
>
>select left(poc,1) as alpha, count(poc)
> from custfl
> group by alpha
>
>Getting error:
>
>Server: Msg 207, Level 16, State 3, Line 1
>Invalid column name 'alpha'.
>
>Can you tell me what is the correct syntax for SQL?

AFAIK, SQL Server won't allow field alias names in the GROUP BY clause unless they are real fields.

Try:
select left(poc,1) as alpha, count(poc)
from custfl
group by left(poc,1)
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform