Re: newbie query (decode) experts opinion wanted ;)
Date: 23 Jan 2002 06:53:01 -0800
Message-ID: <947ef647.0201230652.17d0f2e7_at_posting.google.com>
"Daniel A. Morgan" <damorgan_at_exesolutions.com> wrote in message news:<3C4D5CAD.34CCC41D_at_exesolutions.com>...
> I don't have a lot of time to look at this right now but my first thought would
> be ... what do you mean by a.*,
>
> Did you mean SELECT a.*, b.*
>
> Knowing whether you are retrieving data form 'b' would change my answer.
>
> Daniel Morgan
>
>
> oranewbie wrote:
>
> > I would like some input on if this query, that I've written, 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. Thanks.
> >
> > opinions?
Actually a.* means that I'm getting everything from the table1 that
satisfies the query. I have added the other fields that I want to get
from table2 to make it more clearer.
a.*, b.test_score_min, b.test_score_max, b.department_flag
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')
Received on Wed Jan 23 2002 - 15:53:01 CET
