Get the App
SLTechnology News&Howtos  ›  Database  › 

How to group according to the first letter of a field value in sql

Shulou Source: shulou.com Published: 2022-05-31 19:08:24 11月17日 Update

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.

Tags: Fields groups letters content skills knowledge results concise concise that is articles solutions industries solutions information information channels channels one highlight Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info vpn NVidia MariaDB