I have a table with 1 record per sale per salesperson per day
NAME DATE
joe 1-1-13
joe 1-1-13
joe 1-1-13
dave 1-1-13
joe 1-2-13
I
Use a nested query to get the daily total:
BEGIN
create table #sales (name varchar(10), salesdate date )
insert into #sales (name, salesdate) values
('joe', '01-01-2013'),
('joe', '01-01-2013'),
('joe', '01-01-2013'),
('dave', '01-01-2013'),
('joe', '01-02-2013'),
('dave', '01-02-2013')
SELECT name, salesdate, COUNT(*) AS personDailyTotal, MAX(dailyTotal) AS dailyTotal,
(COUNT(*) * 100.0) / MAX(dailyTotal) AS [Percent]
FROM #sales
INNER JOIN (
SELECT salesdate as [day], COUNT(*) as dailyTotal
FROM #sales
GROUP BY salesdate
) AS [Total] ON salesdate = [day]
GROUP BY name, salesdate
END