| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | juerg(dot)rietmann(at)pup(dot)ch |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: monster query, how to make it smaller |
| Date: | 2001-01-23 16:31:05 |
| Message-ID: | 6477.980267465@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Can't you skip the UNIONing and do this with something like
where (Z_A_nr is NULL
AND Z_umfang = '900' AND Z_blaenge = '2340' AND
Z_durch_soll IN ('286.1', '286.15', '286.20', ...)
AND Z_status = 'zcu'
AND (((Z_durch_soll+0.25)-Z_durch_ist) / 2) >= 0.085
AND (((Z_durch_soll+0.25)-Z_durch_ist) / 2) > 0.12)
?
I'm not sure whether the difference in the last output expression
(Z_durch_soll+0.25 in the first UNION'd select, Z_durch_soll+0.2
in the rest) is intentional or a typo. If it's intentional, you
could write it as something like
CASE WHEN Z_durch_soll = '286.45' THEN Z_durch_soll+0.25
ELSE Z_durch_soll+0.2 END
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2001-01-23 16:54:58 | Re: select returns no line |
| Previous Message | Peter Eisentraut | 2001-01-23 16:27:22 | Re: select returns no line |