This is a case that we didn't think of when writing the QE, though I guess that's only partly true since it did know to put it into separate .xql files (of course, something else may've triggered that, I can't tell without seeing the entire query).
The fix is easy - "select distinct(calendar_id) as calendar_id". This
is the proper SQL92 form and works fine in PG.
My e-mail never seems to go through to you guys, did you get my message that some of the .xql files referenced in the .info file, for the "admin" directory, never got added to the CVS file? Hate to have this conversation in public but your e-mail server seems to be very unreliable.