按字符串的第一个字母分组
我有一个 Person 表,其中有大量记录,并且想按其中重复的人员进行分组, 根据其中一个要求,人员是重复的,如果他们具有相同的姓氏,并且名字的第一个字母相等,所以我想按名字和姓氏的第一个字母进行分组,有没有办法在sql中进行分组像这样?我在C#中需要这个,所以可以完成一些代码处理,但是人数巨大,所以它应该是快速算法。
I have a Person table, with huge number of records, and want to group by duplicate persons in it,
by one of requirements persons are duplicates, if they have the same family name, and the first letter of first names are equal, so I want to group by first name, and first letter of family name, is there a way to group in sql like this? I need this in C#, so some code processing could be done, but the number of persons is huge, so it should be fast algorithm.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话,从 SqlServer 你可以做类似的事情
除此之外,我们需要更多的细节。表模式、预期结果集等...
If I understand you correctly, from SqlServer you can do something like
Other than that, we will need a little bit more detail. Table schema, expected result set, etc...
此查询将为您提供所有(在本例中为成员),其中多个成员的名字相同且姓氏的第一个字母相同。换句话说,重复您所定义的内容。
This query will give you all (members in this case) where the first name is the same and the last name's first letter is the same for more than one member. In other words duplicates as you've defined it.