Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Invalid column name
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00368854
Message ID:
00369139
Vues:
12
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform