Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL Not Exists?

$
0
0

Hi all!

I am trying to construct a query and the logic is not seeming to come to me!

I have a database which holds transactions with a stock reference in each transaction;

Transactions can be labelled as either a being a purchase or a sale within one field for example:

TransactionType = P means a purchase

TransactionsType = S means a sale.

For the sake of explanation I will give a stock item code of StockItem1

You can also have multiple transactions of the same stock item being bought, so there could me many of the following:

StockCode:

StockItem1

TransactionType:

S

I

am trying to work on a query where you can see that stock has been

purchased but not sold with the purchases shown as a result. So

basically, I need to show all Stock where a TransactionType where P

exists but not show this if the same Stock Item also has an entry with S

associated...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>