[英]T-SQL Query to SELECT rows with same values of several columns (Azure SQL Database)
I need help with writing a T-SQL query on a table shown on the picture below. 我需要在下图所示的表上编写T-SQL查询的帮助。 The table has ambiguous info about buildings, some of them appears more then one time, that is wrong. 表格中关于建筑物的信息含糊不清,其中一些不止一次出现,这是错误的。 I need to select only rows that has the same street and building values, for I can manually delete bad rows then. 我只需要选择具有相同街道和建筑物值的行,因为这样我可以手动删除不良行。 So I want to select rows 1,2,4,5 on the picture below. 所以我想在下面的图片中选择行1,2,4,5。 I use an Azure SQL Database, it has some limitations on T-SQL. 我使用Azure SQL数据库,它在T-SQL上有一些限制。
I'm pretty sure Azure supports subqueries and window functions. 我很确定Azure支持子查询和窗口功能。 So, try this: 因此,请尝试以下操作:
select t.*
from (select t.*, count(*) over (partition by street, building) as cnt
from table t
) t
where cnt > 1;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.