Funky GROUP BY

Balestrieri, John jbalestrieri at ap.org
Wed Oct 11 13:14:57 CDT 2006


OK, moving forward slowly... I apologize for bombarding the list like
this... I only deal with DB issues about once every two years... if this is
not the correct list, please let me know.

So, I'm expanding my original query, and have a new error, and want to make
sure I understand it correctly before modifying my database.

The query:

SELECT Race.SeatNumber, Race.OfficeID, Candidate.CandidateID,
Results.CandidateID, Race.RaceCountyID, Results.RaceCountyID,
Race.Meta_State, Sum(Results.VoteCount)

FROM Results, Candidate, Race

WHERE Results.CandidateID = Candidate.CandidateID AND Race.RaceCountyID =
Results.RaceCountyID AND Race.Meta_State='CA' AND Race.OfficeID = 'H'

GROUP BY Race.SeatNumber, Race.OfficeID, Candidate.CandidateID,
Results.CandidateID, Race.RaceCountyID, Results.RaceCountyID,
Race.Meta_State

ORDER BY Race.Seatnumber, Results.VoteCount DESC

The error:
-----
13:01:57: Error: Kernel error: 0x80501
13:01:57: Error: Field name "CandidateID" is not unique.
------

As far as I can tell, the error with the duplicate field is in the GROUP BY
section, where there are collisions between the field names between
different fields once they've been GROUPED. I've unsuccessfully tried column
name aliases as well referencing (once) the CandidateID column by column
name alone (not as tablename.columnname). In this case, is the only solution
to change the name of the original columns when I create the tables, to
avoid duplicate names when the tables are GROUP BYed?

Thanks,
John


The information contained in this communication is intended for the use of the designated recipients named above. If the reader of this communication is not the intended recipient, you are hereby notified that you have received this communication in error, and that any review, dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify The Associated Press immediately by telephone at +1-212-621-1898 and delete this email. Thank you.


More information about the Valentina mailing list