Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: newbie query (decode) experts opinion wanted ;)

Re: newbie query (decode) experts opinion wanted ;)

From: Jon Waterhouse <jonwaterhouse_at_mail.gov.nf.ca>
Date: Wed, 23 Jan 2002 09:48:12 -0330
Message-ID: <3c4eb7ae.0@209.128.1.3>


I'm no expert, but I would think that just a simple logical expression would be faster:

and (b.depflag is NULL or (b.depflag='Y' and a.depflag='Y') or (b.depgflag='N' and a.depflag='N'))

if the only valid values in the flag are Y and N, then you could just have a.depflag=b.depflag

"oranewbie" <teekgeek99_at_hotmail.com> wrote in message news:a606c112.0201221207.160eedf1_at_posting.google.com...
> I would like some input on if this query is the best way to go about
> things. I thought perhaps inclusion of a decode
> statement might make things run faster, but I'm not sure. The two
> tables I'm getting this off of are production and are pretty huge
> (millions of rows). Thanks.
>
> a.*,
> from table1 a,
> table2 b
> where
> ( a.employee_num = b.employee_num and a.test_id = 1 and
> a.employee_num = 'SA' and ((a.test_score >= b.test_score_min
> and a.test_score < b.test_score_max) or
> (a.test_score >= b.test_score_min and b.test_score_max is null
> ) ) and
> (case when b.department_flag is null then '1'
> when b.department_flag = 'Y' and a.department_flag = 'Y'
> then '1'
> when b.department_flag = 'N' and a.department_flag =
> 'N'
> then '1'
> else ' ' end ) = '1')
>
>
> opinions?
Received on Wed Jan 23 2002 - 07:18:12 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US