Removing duplicates values with join 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 &gt;= '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.
Use the next query

SELECT
B.Company,
COUNT(DISTINCT A.Ticket) AS QTY
FROM Table1 A
INNER JOIN Table2 B
ON A.CompanySk = B.EDWCompanySK
WHERE A.StartedDate &gt;= '20171128'
GROUP BY B.Company
ORDER BY QTY DESC