Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need help with query filtering an item based on re

Author  Topic 

mltroman
Starting Member

1 Post

Posted - 2008-12-07 : 13:38:05
I have a query from a transaction table that shows the quantity, cost, tax, item description sold. The product is a service that is delivered later - a ski/snowboard lesson program.

Occasionally, the transaction is reversed in our POS system and so I want to eliminate that sale from the report which is a listing of people in a lesson.

So a typical scenario might be as follows:
Product A is sold but the the person decides they want to change from a one day to multi-day program. So, we 'void' the sale of the Product A and register him for Product B. We don't want him to show up on the Product A list.

The void transaction is a simple reversal of the original transaction. The transaction table has a negative quantity of the original item sold. How can I eliminate the original sale and the void sale from the Product A list by comparing the 2 transactions?

I could use some help with the select statement that will result in the row that will result in the 3rd row in this image: [url]http://mdbmakers.com/forums/attachment.php?attachmentid=5240&d=1228607242[/url]

Thanks in advance.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-07 : 16:29:43
Something similar to

SELECT UserID, SUM(Price) FROM Table1 GROUP BY UserID HAVING SUM(Price) <> 0



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -