Re: select * from (select * from bob) and other easy stuff
Posted in 2006
Topics: General Discussion
internetuser wrote: > thisisawindowname, THIS IS A WINDOW NAME > thisisanotherwindowname, THIS IS ANOTHER WINDOW NAME it won't - just pointing out that you don't *require* upper function in the select clause in order to include it in the where clause. It isn't apparent to me why you would need to show it twice (once uppercased and once in it's natural case). If you already knew that - disregard.
I like Fernado's suggestion (provide some schemas and what exactly you
are trying to accomplish).
My best guess (but without the links between the tables it's a best
some murky sql) is below. It's late and I'm going by memory here on
the case in the where clause - but I believe you can use that syntax (I
never have found a reason to do so though). I think you can also use
the something like this in the where clause: "where case __ when __
then __ end IN (SELECT ... )"
select et_code,
et_desc,
case_type as ct_code,
valid_case_type_desc_txt as ct_desc
from notrust.valid_case_type vct,
notrust.e_type et
where et.e_type_code = vct.et_code -- the join i doubt is true (guess)
and vct.case_type is not null
AND CASE et.e_type_code
WHEN '12A' THEN '265101'
WHEN 'SCHL' THEN '262714'
WHEN 'GPGT' THEN '262730'
WHEN 'TNCGT' THEN '262713'
-- not putting all the elements from your decode function
ELSE ''
END = vct.valid_case_type_code