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

"With this but not this" kind of query in SQL

$
0
0

A strange title I guess!

Basically, I have our client data in SQL and our sales team want to do some cross selling based on clients who have purchased certain products and services but not others.

I have a line of data for a client for each product they purchase so my columns would be similar to below: -

Using the example above I would like to be able to see who has Product 1 but hasnt purchased product 2 (in this case Mr J Smith). If that makes sense? 

I just cant seem to get this right in my head, despite it being a relatively simple request!

Anyone point me in the right direction?

Many thanks


Viewing all articles
Browse latest Browse all 4871

Trending Articles



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