Subject | Re: FB 1.5 final hangs with this exists statement |
---|---|
Author | Svein Erling |
Post date | 2004-03-11T09:58:15Z |
--- In firebird-support@yahoogroups.com, "james_027" wrote:
benefitial if you mentioned the plan chosen and some statistics. I
suspect you need to modify your indexes a bit or change to
select "Cust ID", "Deliver Date", "Grand Total"
from "DR" m
where m."Cust ID" = 205 and not exists (select *
from "DR" d
where d."Cust ID" = 205 and
(m."Grand Total" > d."Grand Total" or 2=0))
Though it all depends on lots of things, e.g. how many records exists
for "Cust ID" 205.
HTH,
Set
> I have this statement that gives me the largest amount of sales forHi James, I like your query, but in order to help you it would be
> the customer with id 205. The result is correct.
>
> select "Cust ID", "Deliver Date", "Grand Total"
> from "DR" m
> where m."Cust ID" = 205 and not exists (select *
> from "DR" d
> where d."Cust ID" = 205 and
> m."Grand Total" < d."Grand Total")
>
>
> However if I want the reverse, the smallest amount of sales for this
> customer 205 my fB didnt stop running even for such a long time, and
> it hangs I think.
>
> select "Cust ID", "Deliver Date", "Grand Total"
> from "DR" m
> where m."Cust ID" = 205 and not exists (select *
> from "DR" d
> where d."Cust ID" = 205 and m."Grand Total" > d."Grand Total")
>
> is there something wrong with this script? or is there a right way
> of doing this?
benefitial if you mentioned the plan chosen and some statistics. I
suspect you need to modify your indexes a bit or change to
select "Cust ID", "Deliver Date", "Grand Total"
from "DR" m
where m."Cust ID" = 205 and not exists (select *
from "DR" d
where d."Cust ID" = 205 and
(m."Grand Total" > d."Grand Total" or 2=0))
Though it all depends on lots of things, e.g. how many records exists
for "Cust ID" 205.
HTH,
Set