asp.net - C# SQL table select and count distinct values -


i have asp website sql database table. in table column mane "type". want distinct values column values count in datatable. example database table:

id  type --------- 1   type1 2   type2 3   type3 4   type2 5   type2 6   type3 

i want following datatable:

type  count ------------ type1   1 type2   3 type3   2 

you can use

select type, count(type) count table1  group type 

result

|  type | count | |-------|-------| | type1 |     1 | | type2 |     3 | | type3 |     2 | 

sqlfiddle demo


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -