Hi everyone,I have a table "BoardPoints" with columns InputRef, WorkingDay, ConsultantRef and Enquiries.I need to pull off a SUM of the Maximum values of Enquiries for each Consultant in any given month.I can do this easily for one consultant with:- SELECT MAX(Enquiries) AS EnquiriesFROM BoardPointsWHERE ConsultantRef = @consultantrefAND WorkingDay BETWEEN ( SELECT DATEADD(s,0,DATEADD(mm, DATEDIFF(m,0,getdate())-1,0)) ) AND ( SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) )
But i need the code to add all of the max Enquiries values for every different consultant, so say BoardPoints contains these records:-InputRef WorkingDay ConsultantRef Enquiries1638 2010-11-16 00:00:00.000 541000005 70 1640 2010-11-16 00:00:00.000 541000020 86 1637 2010-11-16 00:00:00.000 541000019 54 1639 2010-11-16 00:00:00.000 541000018 0 1633 2010-11-15 00:00:00.000 541000019 44 1634 2010-11-15 00:00:00.000 541000005 70 1635 2010-11-15 00:00:00.000 541000018 0 1636 2010-11-15 00:00:00.000 541000020 82 1629 2010-11-14 00:00:00.000 541000019 44 1631 2010-11-14 00:00:00.000 541000018 0I need the query to return 70 + 86 + 54 + 0, so 210Any help would be appreciated.S