如何删除反向值在SQL Server中

时间:2016-10-03 09:19:48

标签: sql-server

我使用以下Query

从SQL获取所有反向值
 table, th, td
{
  border-collapse: separate;
    border-spacing:2px;
    border-style: solid;
    border-width:thin;    
    background-color:White;    
}
table
{
  background-color:Black;
}

我有5000行。我有相同的负值和正值我称其反向值。我从表中得到所有反向值,完全反向值为5000行的1508列。上面我提到Query使用了fetch reverse value。我想删除反向值

1 个答案:

答案 0 :(得分:1)

如果要删除查询返回的完全相同的记录,请按照以下方法进行操作(您只需按比例删除要删除的表的别名):

delete a 
from TotalsByGLCenter$ as a
left join TotalsByGLCenter$ as b on a.APSupplierID = b.APSupplierID AND a.Entity=b.Entity and a.ExpenseReportID=b.ExpenseReportID and a.Employee=b.Employee  and a.Amount = -b.Amount
where b.Amount is not null