Subject | Re: comparing return value of select subquery |
---|---|
Author | Adam |
Post date | 2006-11-10T22:30:21Z |
--- In firebird-support@yahoogroups.com, Svein Erling Tysvaer
<svein.erling.tysvaer@...> wrote:
Your query returns the right result for my test case here, but I am
not yet confident it will return the right result in all situations. I
just need to study it a bit more.
Given that there may be multiple records in tb for every ta record, I
may need to use distinct as well.
Thanks
Adam
<svein.erling.tysvaer@...> wrote:
>Set,
> Hi Adam!
>
> The one alternative I can think of is
>
> select
> ta.a,
> ta.b,
> sum(tb.c) as c
> from ta
> join tb on ta.a = tb.a
> group by ta.a, ta.b
> having ta.b <> sum(tb.c)
>
> Though I don't know if this is better or even gets the result you want
> (more complex may mean that simple solutions do not exist).
Your query returns the right result for my test case here, but I am
not yet confident it will return the right result in all situations. I
just need to study it a bit more.
Given that there may be multiple records in tb for every ta record, I
may need to use distinct as well.
Thanks
Adam