Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto Incremental Value in Query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00807090
Message ID:
00807112
Vues:
20
You can use temp table with IDENTITY column to achive that.
CREATE TABLE #temp (
idnum int IDENTITY,
type char(1) NULL, 
counter int NOT NULL)
INSERT INTO #temp (type, counter)
select	Type,
  count('x') as Counter
  from	Client
  group	by Type
  ORDER BY 1
SELECT * FROM #temp
DROP TABLE #temp
>Hi!
>
>I would like to know how to add an incremental value as a Column in a Query.
>
>e.g.:

>Table: Client.
>Code Name Type
>112533 John A
>421326 Samuel B
>721423 Peter A
>443231 Steve A
>551242 Erick C
>632142 Mariah B
>242312 Carlos B
>
>select as IdNum,
> Type,
> count('x') as Counter
>from Client
>group by Type
>
>
>Result:
>IdNum Type Counter
>1 A 3
>2 B 3
>3 C 1

>Thanks in advance!
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform