We help IT Professionals succeed at work.
Get Started

Query return records that have 2 rows that equal zero

216 Views
Last Modified: 2014-09-04
Hi All,
The following query returns duplicate (so to speak, positive/negative dups) possibilities..
the price is the same and for a duplicate the AMTs equal zero.
How would I limit the query to only give results of the ones that equal zero?
Right now it could return AMTs that equal each other and would not cancel each other.
select 
"DATA_ID",
"DATA_ID" DATA_ID_DISPLAY,
"CUSTNO",
"STORENO",
"SALEDATE",
"INVOICENO",
"UPC",
"SHIPTO",
SHIPNAME,
"PRICE",
"QTY",
"AMT",
"BRANCHNO",
"ITEMNO"
from (SELECT a.*, count(*) over(partition by Custno,Branchno,Shipto,INVOICENO, SALEDATE, UPC, 
			  SHIPTO, PRICE, ABS(AMT)) cnt
       from "#OWNER#"."MY_DATA" a)
where cnt >1
order by Custno,Branchno,Shipto,Invoiceno,Itemno,PRICE,abs(AMT)

Open in new window

Comment
Watch Question
IT-specialist
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE