is this possible? yes/no

Raysoc

Board Regular
Joined
Feb 10, 2009
Messages
227
Just need a simple yes/no.

I have lots and lots of data.
What I wana do is remove any entry if it was later reversed.

i.e. a customer purchases something it costs $20.0
so row 1
Cost Reversal
20 0

a customer then returns said item
row 87
Cost Reversal
0 20

so if the rows custID# num clerk# match in both entries i dont want them coming back in my query of all costs.

is this possible or is this a task for excel for pre or post data mining.

Thanks!
 
For some reason I can not seem to integrate this into my SQL.. it refuses to pick up the Reversal amt...

here is the SQL im using, ive made it as basic as I can to figure it out and plan on adding in the other fields etc later, right now I just want the basics working.

Any help is greatly appreciated.

Code:
SELECT MyTable.Date, [EMP List].Iden, [EMPLOYEELASTNAME] & ' ' & [EMPLOYEEFIRSTNAME] AS [EMP Name], MyTable.[EMP LOB], [EMP List].BP, MyTable.[OBB], MyTable.[CID], MyTable![Adj Amt]+MyTable![Rvrsl Amt] AS TransValue, Sum(MyTable.[Adj Amt]) AS SumOfAdj, Sum(MyTable.[Rvrsl Amt]) AS SumofRvrsl, [SumofAdj]-[SumofRvrsl] AS NetAmt
FROM MyTable LEFT JOIN [EMP List] ON MyTable.[EMP P] = [EMP List].BP
GROUP BY MyTable.Date, [EMP List].Iden, [EMPLOYEELASTNAME] & ' ' & [EMPLOYEEFIRSTNAME], MyTable.[EMP LOB], [EMP List].BP, MyTable.[OBB], MyTable.[CID], MyTable![Adj Amt]+MyTable![Rvrsl Amt], MyTable.[Adj Amt]
HAVING (((MyTable.[Adj Amt])<-500));
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I don't have a lot of time to dive into it right now, but I did notice one thing. You have MyTable.[Adj Amt] in your Group By clause, but not in your SELECT statement (other than in your calculations). I am guessing it is there because you want to use in in your criteria.

Instead of putting the criteria in your HAVING clause, you can put it in the WHERE clause, and then you do not need it in your GROUP BY.

Give that a shot and see if it makes any difference. The code will look something like this:
Code:
SELECT MyTable.Date, [EMP List].Iden, [EMPLOYEELASTNAME] & ' ' & [EMPLOYEEFIRSTNAME] AS [EMP Name], MyTable.[EMP LOB], [EMP List].BP, MyTable.[OBB], MyTable.[CID], MyTable![Adj Amt]+MyTable![Rvrsl Amt] AS TransValue, Sum(MyTable.[Adj Amt]) AS SumOfAdj, Sum(MyTable.[Rvrsl Amt]) AS SumofRvrsl, [SumofAdj]-[SumofRvrsl] AS NetAmt
FROM MyTable LEFT JOIN [EMP List] ON MyTable.[EMP P] = [EMP List].BP
WHERE MyTable.[Adj Amt])<-500
GROUP BY MyTable.Date, [EMP List].Iden, [EMPLOYEELASTNAME] & ' ' & [EMPLOYEEFIRSTNAME], MyTable.[EMP LOB], [EMP List].BP, MyTable.[OBB], MyTable.[CID], MyTable![Adj Amt]+MyTable![Rvrsl Amt];
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,811
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top