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 |
Comments
Post a Comment