I've looked at the examples and I think I should be using a JOIN but I can't get the syntax right and it's nothing but errors. I need to return a table showing Counts based on criteria.
My procedure looks like this
SELECT SalesMan, Count(SalesMan) AS SalesCount
FROM Customers
WHERE SaleDate Between @BeginDate And @EndDate AND Status = 'SOLD'
GROUP BY SalesMan
ORDER BY SalesCount DESC
SELECT DISTINCT SalesMan2, Count(Salesman2) AS HalfCount
FROM Customers
WHERE SaleDate Between @BeginDate And @EndDate AND Status = 'SOLD'
GROUP BY SalesMan2
ORDER BY HalfCount DESC
This Return two tables that look like this
SalesMan | SalesCount
BOB 8
ANDY 5
JOE 3
SalesMan2 | HalfCount
(blank) 40
ANDY 1
JACOB 1
ROB 1
JOE 1
The logic I'm trying to make work is.. If they're Salesman add 1, If they're the Salesman2 then add .5. Plus I get a bunch of empties I don't care about in the 2nd table. I don't need those.
What I need is for it to return this
Salesman | SalesCount
BOB 8
ANDY 5.5
JOE 3.5
JACOB .5
ROB .5
I've looked at a lot of answers but they use Joins with where clauses and strings. They also know what value they're supposed to match up to. Any help pointing me in the right direction would be greatly appreciated. Thanks in advance.