Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5959357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:40:24+00:00 2026-05-22T18:40:24+00:00

I have a oracle query and part of it is calculating some value using

  • 0

I have a oracle query and part of it is calculating some value using DECODE. For example:

SELECT ..., 
      (SELECT DECODE((SELECT 23 FROM DUAL), 
                      0, null,
                     (SELECT 23 FROM DUAL))  
         FROM DUAL) 
  FROM ...

Here the value “23” gets calculated at runtime, and it’s quite complicated joins – multiple tables, uses PARTITION BY etc. So I want to avoid executing the same subquery if the value is not “0”. Is there any way to write something like this

SELECT ..., 
       (SELECT DECODE ((SELECT 23 FROM DUAL) as test, 
                        0, null,
                       test)  
         FROM DUAL) 
  FROM ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:40:24+00:00Added an answer on May 22, 2026 at 6:40 pm

    Will this work for you?
    I’ve just moved the “23” to an inline table with a descriptive alias.

    select ..., 
      (
       select 
         decode ( 
                computed_value.val, 
                0, null,
                computed_value.val
                )  
       from
         (select 23 as val from dual) computed_value
      )
    from
      ...
    

    A CASE statement might also add clarity, as in:

    select
      ...
     ,case when computed_value.val = 0
           then null
           else computed_value.val
           end as my_field
    from
      (select 23 as val from dual) computed_value
      ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an " select * from tables..joins... " query on an oracle database,
Ok SQL and Oracle gurus I have a somewhat complicated query that I'm trying
On my SQL 2005 server, I have a linked server connecting to Oracle via
As part of an effort to stop using dynamic SQL generation and encourage use
I have an Oracle table with two columns ID and START_DATE, I want to
I have an oracle function which is given below. when I run this in
I have an Oracle database (roughly 1.2 billion records) of data with a web
I have a master table (hereafter called SURVEY) and a detail table (hereafter called
I am writing a full database extract program in java. Database is Oracle, and
i have 2 tables table1: num,X,Y table2: num,X,Y i need to update X and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.