Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to simplify this query

RituAug 14 2020 — edited Aug 15 2020

Hi,

I'm relatively new to SQL. I was wondering if there is something redundant in the query below - because I'm doing the same WHERE clause in the main query and the subquery.

SELECT category,

(CASE (SELECT COUNT(*) FROM systemvalues WHERE systemtypeid = 'xxxx' AND valuecode = 'yyyy')

    WHEN 1 THEN alphavalue

    WHEN 0 THEN numvalue

END) AS value

FROM systemvalues

WHERE systemtypeid = 'xxxx' AND valuecode = 'yyyy'

Thanks.

Comments
Post Details
Added on Aug 14 2020
5 comments
494 views