将不具有 6 个或更多同名不同地址的记录放入新表中
如果重复的名称超过 6 个,并且同一名称有 6 个不同的地址,那么我不想将它们输出到 KeepThese 表:
harry baker 1 street
harry baker 2 street
harry baker 3 street
harry baker 4 street
harry baker 5 street
harry baker 6 street
donald ross 11th street
因此应该从新表中排除 harry Baker。唐纳德·罗斯应包含在新表中。
这是我现有的查询:
SELECT F.* INTO KeepThese
FROM final_output AS F
INNER JOIN (SELECT DISTINCT F.fullName FROM final_output
AS F LEFT JOIN (SELECT fullName FROM final_output
AS F GROUP BY fullName HAVING COUNT(*) >=6)
AS NamesToReject ON NamesToReject.fullName = F.fullName WHERE NamesToReject.ID IS NULL)
AS NamesToKeep ON NamesToKeep.fullName = F.fullName;
这返回“输入参数值 NamesToReject.ID” 但这是我能想到的最好的。
If the names repeated is more than 6 and there are six different addresses for that same name, then I don't want to output them to the KeepThese table:
harry baker 1 street
harry baker 2 street
harry baker 3 street
harry baker 4 street
harry baker 5 street
harry baker 6 street
donald ross 11th street
So harry baker should be excluded from new table. donald ross should be included in new table.
This is existing query that I have:
SELECT F.* INTO KeepThese
FROM final_output AS F
INNER JOIN (SELECT DISTINCT F.fullName FROM final_output
AS F LEFT JOIN (SELECT fullName FROM final_output
AS F GROUP BY fullName HAVING COUNT(*) >=6)
AS NamesToReject ON NamesToReject.fullName = F.fullName WHERE NamesToReject.ID IS NULL)
AS NamesToKeep ON NamesToKeep.fullName = F.fullName;
This returns "Enter Parameter Value NamesToReject.ID"
But this is best I could come up with.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样:
到目前为止,任何少于六个相同名称的名称和地址组合都会显示。
如果添加下一条语句,则将仅显示每个名称中的一个以及随机选择的该名称的一个地址。
How about :
Up to this point, any name and address combination with less than six of the same name will be shown.
If this next statement is added, only one of each name will be shown with one address for that name, chosen at random.