[英]numbers into group?
In the database table, I have about 1 million record. 在数据库表中,我有大约一百万条记录。
In the number
field there are about 11 digits number. 在
number
字段中,大约有11位数字。
If the 5 digit number is the same, I want to group it so I can export it later. 如果5位数字相同,则我希望将其分组,以便以后导出。
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 您会看到有两组数字,分别是07712和07454
In the group
field I could declare the group name in number? 在
group
字段中,我可以用数字声明组名称吗?
select SUBSTR(number, 1, 5) Groupnumber, number
from yourtable
您可以尝试GROUP BY SUBSTR(number, 1, 5)
或GROUP BY LEFT(number, 5)
。
select LEFT(data, 5) Groupnumber, count(id)
from test
group by Groupnumber;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.