Subject | Re: [firebird-support] [Qry][Err:-206]Column does not belong to referenced table |
---|---|
Author | Ann W. Harrison |
Post date | 2006-02-08T21:36:31Z |
Andrea Raimondi wrote:
You're asking Firebird to compute the average of a group whose
membership is determined by the average you're computing.
you're asking for, I think, is ordering. Do you get what you
want with this query?
select msgs.*,
(select avg (rtg.ratingvalue) from messagesratings rtg
where rtg.message_id = msgs.message_id) as AvgRate
from Messages msgs
order by AvgRate
I greatly prefer to see the actual list of fields from the
messages table, but ... In any even, if you use aliases, use
them consistently. Firebird V2 insists on that point.
Regards,
Ann
> Hello.That's not going to work ... How would you expect it to work?
>
> This is a prettily tricky query in fact.
> Here it is:
>
> select Messages.*,avg(MessageRatings.ratingvalue) as AvgRate
> from Messages
> join messageratings mg on mg.message_id = Messages.message_id
> group by AvgRate
You're asking Firebird to compute the average of a group whose
membership is determined by the average you're computing.
> I simply want to group messages by the ratings they received fromI think you don't understand what group by means in SQL. What
> users, that is - the ones higher rated get showed up before less
> rated ones. All, of course, relative to thread.
you're asking for, I think, is ordering. Do you get what you
want with this query?
select msgs.*,
(select avg (rtg.ratingvalue) from messagesratings rtg
where rtg.message_id = msgs.message_id) as AvgRate
from Messages msgs
order by AvgRate
I greatly prefer to see the actual list of fields from the
messages table, but ... In any even, if you use aliases, use
them consistently. Firebird V2 insists on that point.
Regards,
Ann