Substitute the 3 in the first line to see more than the top 3...
SELECT TOP 10
c1.company
,c1.contact
,SUM(CAST(ch.duration AS MONEY)) AS TotalSales
,COUNT(ch.duration) AS SalesCount
,ch.accountno
FROM
contact1 c1
JOIN conthist ch
ON c1.accountno=ch.accountno
WHERE
ch.srectype = 'S'
GROUP BY
c1.contact
,c1.company
,ch.accountno
ORDER BY
SUM(CAST(ch.duration AS MONEY)) DESC
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.