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

  • SEARCH
  • Home
  • 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 1099671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:46:05+00:00 2026-05-17T00:46:05+00:00

This works: SELECT (CASE WHEN x = ‘value’ THEN a.col1 ELSE nvl(a.col1, a.col2) END)

  • 0

This works:

 SELECT (CASE
             WHEN x = 'value' THEN
              a.col1
             ELSE
              nvl(a.col1, a.col2)
           END)
      FROM table1 a
     WHERE a.this = 'that'
     GROUP BY (CASE
                WHEN x = 'value'  THEN
                 a.col1
                ELSE
                 nvl(a.col1, a.col2)
              END)

But trying to have the case statement do an IN statement(trying for a more dynamic sql here), the following code results to an ORA-00979 error.

SELECT (CASE
         WHEN x IN (SELECT me FROM here WHERE this = 'example') THEN
          a.col1
         ELSE
          nvl(a.col1, a.col2)
       END)
  FROM table1 a
 WHERE a.this = 'that'
 GROUP BY (CASE
            WHEN x IN (SELECT me FROM here WHERE this = 'example') THEN
             a.col1
            ELSE
             nvl(a.col1, a.col2)
          END)

Is it possible to make this work or have an alternative? Thanks.
–Jonas

Benoit: Here’s a modified sql based on your sql that recreates the error:

select (case when a.y IN (select 'A'||ROWNUM from dual where rownum=1) then 1 else 0 end)
from (SELECT 'A'||ROWNUM y, 'B' x FROM DUAL CONNECT BY ROWNUM <= 3) a where x = 'B'
group by (case when a.y IN (select 'A'||ROWNUM from dual where rownum=1) then 1 else 0 end)
;

Basically what was missing was that the FROM table should have more than one values and that a column was referenced in the CASE statement.

  • 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-17T00:46:06+00:00Added an answer on May 17, 2026 at 12:46 am

    I cannot reproduce this error with following request (working):

    select (case when 'X' IN (select dummy from dual where rownum=1) then 1 else 0 end)
    from dual
    where dummy = 'X'
    group by (case when 'X' IN (select dummy from dual where rownum=1) then 1 else 0 end)
    ;
    

    Try:

    WITH table1_extended AS (
       SELECT a.*, CASE WHEN x IN .... END "condition"
         FROM table1 a
    )
    SELECT b."condition"
      FROM table1_extended b
     WHERE b.this = 'that'
     GROUP BY b."condition"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this subquery works in SQL Server: select systemUsers.name, (select count(id) from userIncidences where idUser
Why doesn't this work (when parameter is set to 1) : SELECT * FROM
Will a query like this on a recordset work rs.open select * from table
Hi why doesn't this work in SQL Server 2005? select HALID, count(HALID) as CH
How come this doesn't work (operating on an empty select list <select id=requestTypes></select> $(function()
The following doesn't work, but something like this is what I'm looking for. select
This works (prints, for example, 3 arguments): to run argv do shell script echo
This works, but is it the proper way to do it??? I have a
This works just fine: protected void txtTest_Load(object sender, EventArgs e) { if (sender is
Could someone explain why this works in C#.NET 2.0: Nullable<DateTime> foo; if (true) foo

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.