Reputation: 10828
In the database table, I have about 1 million record.
In the number
field there are about 11 digits number.
If the 5 digit number is the same, I want to group it so I can export it later.
How to archive this?
For example:
077129342480
074545344535
077127777476
077126565656
074546546654
You can see there are two group of number which are 07712 and 07454
In the group
field I could declare the group name in number?
Upvotes: 0
Views: 88
Reputation: 8424
select LEFT(data, 5) Groupnumber, count(id)
from test
group by Groupnumber;
Upvotes: 1
Reputation: 160833
You can try GROUP BY SUBSTR(number, 1, 5)
or GROUP BY LEFT(number, 5)
.
Upvotes: 1