Hi,
I need some help with my sql query below. The results I'm getting back for the Electorate is way higher than it should be, I think its somehow totalling it in both dbo.Candidate and dbo.DivElection.
(dbo.Candidate has DivElecID in it numerous times due to the multiple candidates in a DivElecID)
Any help greatly appreciated, any further explanations needed please let me know. Cheers guys and gals.
Sila
I need some help with my sql query below. The results I'm getting back for the Electorate is way higher than it should be, I think its somehow totalling it in both dbo.Candidate and dbo.DivElection.
(dbo.Candidate has DivElecID in it numerous times due to the multiple candidates in a DivElecID)
Any help greatly appreciated, any further explanations needed please let me know. Cheers guys and gals.
Sila
Code:
SELECT ROUND(SUM(dbo.Candidate.VotesReceived)
/ SUM(dbo.DivElection.Electorate) * 100, 2) AS Percentage,
SUM(dbo.Candidate.VotesReceived) AS Turnout,
SUM(dbo.DivElection.Electorate) AS Electorate
FROM dbo.DivElection inner JOIN
dbo.Candidate ON dbo.DivElection.DivElecID = dbo.Candidate.DivElecID
WHERE (dbo.DivElection.ElectionID = @ElectionId)