How To…Group on First Letter

Question

“How do I group on the first letter of a field?”

Solution

The easiest way to accomplish this is to taylor your original SQL code to your grouping needs.  If you add a field that only selects the first letter of another field, grouping on that field is very easy from ReportBuilder.  In most DB’s you can use the SUBSTRING function to extract part of a string.

Download: GroupByFirstLetter.zip

Sample SQL code:

SELECT CustNo, Company, SUBSTRING(Contact FROM 1 FOR 1) as FirstLetter, Contact FROM Customer
WHERE CustNo < 2000
ORDER BY Contact