Question : Help with SQL Query GROUP BY and COUNT.

I have a table that has a column called FileExtension.

I would like to know a SQL statement that would return two things. Extension and Total Count.

I basically want to group them by extension and give a total for each extension type.

Note: I don't want to hard-code the extension, I will never no all the file extensions that might be available.

Thanks!



Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Using the sample data below, I would want my results to be something like:
 
[Extension]  [Total Count]
   doc             5
   xls             2
   txt             2
   gif             1
   htm             1
 
Sample values:
doc
doc
xls
doc
gif
htm
doc
xls
txt
txt
doc
Open in New Window Select All

Answer : Help with SQL Query GROUP BY and COUNT.

Oops..

select FileExtension, count(FileExtension) as TotalCount from Table
group by FileExtension
Random Solutions  
 
programming4us programming4us