I'm totally new to the land of databases. I'm wanting to get the total of more than one column from my database so am doing this... (below). The problem is, when it is returning the total for each column it isn't limiting it to the last 7 rows by date. It's returning the total for that consultant.
$result = mysql_query("SELECT SUM(NewPermJobs) AS NewPermJobsTotal,
SUM(CandidatesSubmitted) AS CandidatesSubmittedTotal, SUM(FirstInterviewsRecorded)
AS FirstInterviewsRecordedTotal, SUM(OldJobsReactivated) AS OldJobsReactivatedTotal,
SUM(CandidateRecordsUpdated) AS CandidateRecordsUpdatedTotal, SUM(CompaniesAddedDream)
AS CompaniesAddedDreamTotal, SUM(SocialContentShared) AS SocialContentSharedTotal,
SUM(ApplicantStatusChanged) AS ApplicantStatusChangedTotal, SUM(JobsClosed) AS
JobsClosedTotal, SUM(Revenue) AS RevenueTotal FROM dailyactivity WHERE (`Consultant`
LIKE '%".$query."%') ORDER BY Date DESC LIMIT 0,7");?>
It's probably really messy but is the best I can put up at this stage. Any idea why it isn't limiting the sum of the columns to the last 7 ordered by date desc?
Any help would be amazing!