How to group according to the first letter of a field value in sql
This article shows you how to group according to the first letter of a certain field value in sql. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
How are they grouped by the first letter of a field value in sql?
If a field has a value:
X001
X003
P005
Y0093
The grouping result should be .X = 2, pencil1, 1, and 1.
-solution-
If a field has a value:
X001
X003
P005
Y0093
The grouping result should be .X = 2, pencil1, 1, and 1.
Select left (col,1), count (*) from tb group by left (col,1)
The above is how to group according to the first letter of a field value in sql. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.