删除其他行中具有相同值的sql行

时间:2015-05-08 11:33:29

标签: sql-server-2008-r2 rows

我的表格数据为:

 {
    "status" : "CREATED",
    "message" : "user created",
    "results" : [
        {
            "id" : "1243233",
        }
    ]
}

我要删除第4,5,6行。所有行的C2 = 0,具有相同的C1和C2 = 1.建议?

1 个答案:

答案 0 :(得分:0)

delete from your_table
where c2 = 0
and c1 in 
(
  select c1
  from your_table
  where c2 in (0,1)
  group by c1
  having count(distinct c2) = 2
)