I have some data - grouped by col LineNum - What I need to be able to do - is to remove all rows that off set each other with the negative and positive totalOrg values - so in any event that a row has 2 positive and one negative - remove both the positive and negative (totalOrg) row (where all other values beyond claimDetailID are equal) and leave the remaining positive...
DROP TABLE #table
CREATE TABLE #table (linenum int,   HCPCSOrg varchar(10),   reimbOrg money, unitsOrg           int, totalorg money, claimdetailID int,  comments varchar(500))
INSERT INTO #table
SELECT 1,   '84443',    22.93,  1,  -82.00  ,1072766,   'Status: N - No Other Lab Codes         In Claim - Reimb ClinLab'
UNION ALL
SELECT 1,   '84443',    22.93,  1,  82.00,  1072767,    'Status: N - No Other Lab Codes In Claim - Reimb ClinLab'
UNION ALL
SELECT 1,   '84443',    22.93,  1,  82.00,  1072768,    'Status: N - No Other Lab Codes     In Claim - Reimb ClinLab'
UNION ALL
SELECT 2,   '36415',    3.00,   1,  -15.00, 1072769,    'Status: N - No Other Lab Codes In Claim - Reimb ClinLab'
UNION ALL
SELECT 2,   '36415',    3.00,   1,  15.00,  1072770,    'Status: N - No Other Lab Codes In Claim - Reimb ClinLab'
UNION ALL
SELECT 2,   '36415',    3.00,   1,  15.00,  1072771,    'Status: N - No Other Lab Codes In Claim - Reimb ClinLab'
UNION ALL
SELECT 3,   '87621',    47.87,  1,  227.00, 1072772,    'Status: N - No Other Lab Codes In Claim - Reimb ClinLab'
UNION ALL
SELECT 3,   '85025',    10.61,  1,  40.00,  1072773,    'Status: N - No Other Lab Codes In Claim - Reimb ClinLab'
UNION ALL
SELECT 3,   '85025',    10.61,  1,  -40.00, 1072774,    'Status: N - No Other Lab Codes In     Claim - Reimb ClinLab'
UNION ALL
SELECT 4,   'G0123',    27.64,  1,  -74.00, 1072775,    'Status: A - Found in ClinLab'
UNION ALL
SELECT 4,   'G0123',    27.64,  1,  74.00,  1072776,    'Status: A - Found in ClinLab'
UNION ALL
SELECT 4,   '85025',    10.61,  1,  40.00,  1072777,    'Status: N - No Other Lab Codes     In Claim - Reimb ClinLab'
UNION ALL
SELECT 5,   'G0123',    27.64,  1,  74.00,  1072778,    'Status: A - Found in ClinLab'
SELECT * FROM #table
 
     
    