Subject | Re: [firebird-support] Re: question about joins |
---|---|
Author | Michael Weissenbacher |
Post date | 2007-02-28T16:35:13Z |
Hi,
thought that up. Pity that I can't withdraw yesterday's mail now without
a time machine :)
would be the way to go then.
Michael
> Nope, it depends on the number of matching records in the otherOoops, sorry, you are right. I guess my mind went the wrong way when I
> table(s). With his example:
> ...
> To get the sum of the individual table, he would want sum(s.sales)/3 and
> sum(c.costs)/2.
thought that up. Pity that I can't withdraw yesterday's mail now without
a time machine :)
> select m.id, sum(s.sales)/(select count(*) from coststable c2Exactly, thanks for the clarification. Subselects or 2 seperate selects
> where c2.id = m.id), sum(c.costs)/(select count(*) from salestable s2
> where s2.id = m.id)
> from maintable m
> left join salestable s on s.id = m.id
> left join coststable c on c.id = m.id
> where m.id = 1
> group by m.id
>
> Though I cannot think of any situation where this would be preferrable
> to a simple subselect.
would be the way to go then.
Michael