-2

How do I a query in SQL Server using T-SQL to return the counts of the first letter/character in a column's values?

Robert Bernstein
  • 783
  • 12
  • 18

1 Answers1

5
SELECT SUBSTRING(FileName, 1, 1) as first_letter, COUNT(FileId)  
FROM Files  
GROUP BY SUBSTRING(FileName,1,1)  
ORDER BY first_letter  

I modified an example for Oracle that can be found here: group by first character

Community
  • 1
  • 1
Robert Bernstein
  • 783
  • 12
  • 18