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.
Author |
Topic |
loiter
Starting Member
7 Posts |
Posted - 2012-10-23 : 14:08:02
|
Hello, My TSQL knowledge has hit the wall and I need a push. I have a CTE with dups of sales. 4 columns: product-guid, salesman-guid, sale, count.The sales activity table has all the sales, BUT, I want to only pull the sales for the dup-sales, I don't want all the sales from the sales people that are in the dup CTE, which is what I get if I inner join.The sales activity table has both GUIDS.TIA,Loit |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-10-23 : 15:35:23
|
Instead of joining to the CTE, join to a virtual table derived from CTE:....FROM( SELECT DISTINCT product -guid, salesman -guid FROM CTE) AS vINNER JOIN SalesActivityTable s ON s.product -guid = v.product -guid AND s.salesman -guid = v.salesman -guid |
 |
|
loiter
Starting Member
7 Posts |
Posted - 2012-10-24 : 07:51:06
|
Super, thanks Sunita, I was doing a second join for the other guid instead of using 'And'.Loit |
 |
|
|
|
|