I have a query that looks like this:
SELECT
B.Company,
COUNT(*) AS QTY
FROM Table1 A
INNER JOIN Table2 B
ON A.CompanySk = B.EDWCompanySK
WHERE A.StartedDate >= '20171128'
GROUP BY B.Company
ORDER BY QTY DESC
However, there is a field name "Ticket" in table1 that has duplicate values, that I need to exclude. How can I return the count with excluding duplicate "ticket" values.
Best Answer
Use the next query