Stumped on a query
I am hoping that you can help me. It has been so long since I have had to do anything other than simple queries in SQL that I am struggling to solve a problem. Let’s say I have a table with one column named FileExtensions, and the values in the column are as follows: .PDF .DOCX .PPTX .PDF .DOCX .PPTX .PDF .DOCX .PPTX .PDF .PDF .PDF .DOCX .DOCX .PPTX I need to write a query that will give me the following summary results showing how many of each file extension are present in the column: FILEEXT COUNT .PDF 6 .DOCX 5 .PPTX 4 The example above is a simplification of the need because I can't just use hard coded values for the extensions in the WHERE statement because they will not be known in advance. Any ideas?
November 2nd, 2010 10:40pm

SELECT FILEEXT, COUNT)FILEEXT) as CT FROM TableName GROUP BY FILEEXT Please be aware that this is an SSRS forum rather than an SQL Queries forumRgds Geoff
Free Windows Admin Tool Kit Click here and download it now
November 2nd, 2010 11:01pm

This should do it select FILEEXT, COUNT(*) from [Table] group by FILEEXT order by COUNT(*) DESC Craig Bryden - Please mark correct answers
November 2nd, 2010 11:02pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics