NOT IN clause in State of the CASE statement does not

Dear friends,

I want to use on the condition in the WHERE clause of my SELECT statement.

WHERE <>...
<>...
AND eihf.exr_aip_asset_sid NOT IN
(CASE when safa.fund_relation = 'C' and safa.fund_account_code! = vFundAccount)
SO (37874,37909,43424,55040,59513,59598,58570,76148,75885,75927)
ON THE OTHER
(0)
END
)

But it gives me an error like "missing of good parenthis."

Help, please.

Kind regards
Jonathan

You can not write a list of values within the case statement.

try something like this,

 WHERE
<------------->
   AND CASE WHEN safa.fund_relation = 'C' AND safa.fund_account_code != vFundAccount
         THEN eihf.exr_aip_asset_sid ELSE 1 END
       NOT IN (37874, 37909, 43424, 55040, 59513, 59598, 58570, 76148, 75885, 75927)
   AND CASE WHEN safa.fund_relation = 'C' AND safa.fund_account_code != vFundAccount
         THEN 1 ELSE eihf.exr_aip_asset_sid  END != 0;

Tags: Database

Similar Questions

  • EXTRACT function can be used directly in the CASE statement WHEN

    I wrote the following SELECT statement. The function 'calc_time_diff' is a stored function that subtracts two timestamps and returns the result to the total number of seconds. My DBA does not 'calc_time_diff' as a stored function, then, I replaced the third line (in bold) in the SELECT statement with this:

    COUNTY ( BOX WHEN (extract (DAY OF v_end_ts-v_st_ts) * 24 * 60 * 60) +)

    (extract (HOUR FROM v_end_ts-v_st_ts) * 60 * 60) +.

    (excerpt (v_end_ts-v_st_ts MINUTE) * 60) +.

    extract ((DEUXIÈME à PARTIR de v_end_ts-v_st_ts) < 3600 THEN 1 END) less_than_1_hrs_count

    But the CASE above does not work. It returns the same value as COUNT (*). If the total number of tickets is 32 output will be

    total_tickets less_than_1_hrs_count

    32                                 32

    If I call the "calc_time_diff" then I get the correct result. What I'm doing wrong here?

    **********************************************************************************************************************************************************************

    SELECT

    Count (*) total_tickets,

    COUNTY ( CASE WHEN END of calc_time_diff (t.created_date, h.closed_date) < 3600 THEN 1) less_than_1_hrs_count

    OF n01.cc_ticket_info t

    JOIN IN-HOUSE

    (SELECT ticket_id, MAX (created_date) closed_date

    OF n01.cc_ticket_status_history

    WHERE ticket_status = 'CLOSED' AND created_date > = 18 August 2013 ' AND created_date < (to_date('08/24/2013','MM/DD/YYYY') + interval '1' DAY)

    GROUP BY ticket_id

    ) h

    WE (t.ticket_id = h.ticket_id)

    INNER JOIN n01.cc_ticket_notes n

    WE (n.created_date = h.closed_date)

    WHERE (t. ticket_status = 'NOTIFICATION' t.ticket_status 'CLOSED' = GOLD) AND t.created_date > = 18 August 2013 ' AND t.last_changed < to_date('08/24/2013','MM/DD/YYYY') + interval '1' DAY);

    ***********************************************************************************************************************************************************

    create or replace

    FUNCTION calc_time_diff)

    p_st_ts N01.cc_ticket_info. Type of LAST_CHANGED %,

    p_end_ts N01.cc_ticket_info. Type of LAST_CHANGED %)

    RETURN NUMBER

    AS

    v_no_sec NUMBER;

    v_st_ts N01.cc_ticket_info. Type of LAST_CHANGED %;

    v_end_ts N01.cc_ticket_info. Type of LAST_CHANGED %;

    BEGIN

    v_st_ts: = p_st_ts;

    v_end_ts: = p_end_ts;

    SELECT (extract (DAY OF v_end_ts-v_st_ts) * 24 * 60 * 60) +.

    (extract (HOUR FROM v_end_ts-v_st_ts) * 60 * 60) +.

    (excerpt (v_end_ts-v_st_ts MINUTE) * 60) +.

    excerpt ((SECOND from v_end_ts-v_st_ts)

    IN v_no_sec

    DOUBLE;

    Return v_no_sec;

    END calc_time_diff;

    Hello

    You don't need a function defined by the user or the EXTRACT to find the difference between two timestamps.

    SELECT COUNT (*) AS total_tickets

    , COUNTY ( BOX WHEN h.closed_date < t.created_date="" +="" interval="" '1'=""> )

                         THEN 1

    END

    ) AS less_than_1_hrs_count

    ...

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • TDE is not "transparent" to the CASE statement

    Hello

    I have installed oracle (10) database with TDE. It works very well with almost all queries. But I have problems when I try to use the CASE statement.


    He comes to the table, I created:

    {color: #0000ff} create table t_test)
    col1 varchar (128)); {color}

    This query returns an empty result (as planned, because there is still no data in the table).

    {color: #0000ff} to select)
    When col1 = 'test' then 'test '.
    end) as Carter
    of t_test
    {color}
    I now encrypt the column with the following statement:

    {color: #0000ff} change alter table t_test (col1 encrypt using "AES256" without salt); {color}

    And try again the same statement:

    {color: #0000ff} to select)
    When col1 = 'test' then 'test '.
    end) as Carter
    of t_test
    {color}
    He now returns {color: #ff0000} ORA-00932 inconsistent data types: expected BINARY got {color} CHAR

    But if I try:

    {color: #0000ff} select *.
    of t_test
    {color}
    There is no errors (returns empty result, as expected).

    I tried even with data, with the same result.

    Could someone please tell me what I'm doing wrong here?

    Thank you.

    You touch the Bug 6262107 'ORA-932 of the CASE expression sought with encrypted column:

    Description:
    "ORA-932 incompatible data types: expected BINARY got TANK ' is triggered.
    on a query with a case expression sought on a column with TDE.

    for example:
    CREATE TABLE TDE_TEST (COL1 VARCHAR2 (1));
    INSERT INTO TDE_TEST VALUES('1');
    ALTER TABLE TDE_TEST CHANGE (COL1 ENCRYPT WITHOUT SALT);
    SELECT CASE WHEN COL1 = '1', THEN 'A' OF ANOTHER END 'B' OF TDE_TEST;
    ^
    ORA-00932: inconsistent data types: expected BINARY got TANK

    Workaround solution:
    Convert a simple case of the searched case expression expression.

    So, I updated the sql works:
    SQL > select (case col1
    2 when 'test' then 'test '.
    3 end) as Carter
    4 * of t_test
    /
    no selected line

    I hope this helps.

  • Syntax of the case statement / WHEN

    The table I use a depreciation per fiscal year and the fiscal period.  I try to have the amount of depreciation to go to 2 different columns based on the fiscal year and the fiscal year.  I'm doing it with a nested case statement. I know that is not correct, because I get the message ORA-00905.  I'm relatively new to sql and it is contribtuing to my problem as well.  Here is the code I have and suggestions / corrections would be appreciated.  Thanks for the help...

    SELECT

    lao PDR. DEPTID as DEPTID,

    lao PDR. ASSET_ID as ASSET_NO,

    PA. Descr as DESCRIPTION,

    lao PDR. ACCOUNT_AD as AD_ACCT,

    PDL. DE_ACCT, to take into ACCOUNT

    lao PDR. ADEATH as AMT_DEPR,

    PDL. JOURNAL_ID as JRNL_ID,

    PDL. JOURNAL_DATE as JRNL_DT,

    lao PDR. FISCAL_YEAR as FY,

    lao PDR. ACCOUNTING_PERIOD AP,

    CASE

    WHEN RDP. FISCAL_YEAR = 2014 THEN

    WHEN RDP. PERIOD ACCOUNTANT = 11 THEN pdr. DEPR

    END AS CURR_MONTH,

    CASE

    WHEN RDP. FISCAL_YEAR <>2014

    WHEN RDP. ACCOUNTING PERIOD <>11 THEN pdr. DEPR

    END AS PRIOR_MONTH

    OF PS_DEPR_RPT pdr

    INNER JOIN PS_DIST_LN pdl

    THE pdl. BOOK = pdr. BOOK

    AND pdl. BUSINESS_UNIT = pdr. BUSINESS_UNIT

    AND pdl. FISCAL_YEAR = pdr. FISCAL_YEAR

    AND pdl. ACCOUNTING_PERIOD = pdr. ACCOUNTING_PERIOD

    AND pdl. ASSET_ID = pdr. ASSET_ID

    AND pdl. CF_SEQNO = pdr. CF_SEQNO

    INNER JOIN PS_ASSET PA

    WE pa. ASSET_ID = pdl. ASSET_ID

    AND pa. BUSINESS_UNIT = pdl. BUSINESS_UNIT

    WHERE

    lao PDR. BUSINESS_UNIT = "A0465.

    AND pdr. BOOK = 'RUN '.

    AND ((pdr. FISCAL_YEAR = 2014 AND pdr. ACCOUNTING_PERIOD = 11) OR (pdr. FISCAL_YEAR = 2014 AND pdr. ACCOUNTING_PERIOD = 10))

    Hello

    2713822 wrote:

    Thank you... I appreciate the information you provide when you answer these questions.  I always try to get the amount (from the same column) for 2 rows in different columns.  I tried the LAST_VALUE and LAG but it took a long time for the queries to run, I'm looking for another way to do the same.  I'm only using SQL to retrieve data.  I don't have the ability to create or insert.

    I looked the information above and the CASE statement to look like this:

    CASE

    WHEN RDP. FISCAL_YEAR = 2014

    AND pdr. ACCOUNTING_PERIOD = 11

    THEN the RDP. ADEATH AS CURR_MONTH

    ON THE OTHER

    lao PDR. ADEATH AS MONTHS PREVIOUS

    END

    But I'm now getting an "ORA-00905: lack of keyword" message.

    What I'm trying to do is to draw 2 lines 1 to 2014 / 11 and another for 2014 / 10.  The amount for the period 2014 / 11 should go in the current column and the amount for the period 2014 / 10 should go in the previous column.

    Before current assets management

    01 AB01 50.01 50.03

    ....

    If you want to give an alias for a column, then you can say "AS nome_alias" after that tell you what that is in this column.

    'AS nome_alias' applies to the entire column.  Cannot use 'alias_name' in the middle of an expression, for example, in the middle of a CASE expression, before the END keyword.

    If you want to have 2 separate output columns, curr_month and prior_month to your output, you must then 2 separate columns in your SELECT clause.  for example:

    SELECT pdr.branch

    pdr.asset

    CASE

    WHEN pdr.fiscal_year = 2014

    AND pdr.accounting_period = 11

    THEN pdr.depr

    END AS curr_month

    CASE

    WHEN...

    THEN...

    END AS prior_month

    PDR

    ;

    If post you some sample data (CREATE TABLE and INSERT statements), the results and explanations, I could show you how to complete the... sections.

    To find out what version of Oracle you have, use

    SELECT *.

    SINCE the release of v$.

    The output can be messy, like this:

    BANNER

    -------------------------------------------------------------------

    CON_ID

    ----------

    12 c Oracle database Release 12.1.0.1.0 - 64 bit Production

    0

    PL/SQL Release 12.1.0.1.0 - Production

    0

    CORE Production 12.1.0.1.0

    0

    AMT for 64-bit Windows: Version 12.1.0.1.0 - Production

    0

    NLSRTL Version 12.1.0.1.0 - Production

    0

    The important thing is the number 5 parts on the first line; 12.1.0.1.0 in the example above.

  • Problem with the case where the clause

    Hello

    I want to use cases in which clause. I wrote a very simple query to test how it works. However, I always got an error message. Here's what I did.

    Select eid, firstname, lastname from employee where eid = 1 works fine

    Select eid, name, name of the employee

    where

    cases where 1 = 1 then eid = 1

    When 1! = 1 then eid = 2

    end

    I ORA-00905: lack of keyword.

    Did I miss something?

    Thank you

    Jennifer

    Hi, Jennifer.

    Why do you want to use BOX in a WHERE clause?  The wonderful thing about the CASE is that it allows you to do IF-THEN-ELSE logic.  In a SELECT clause, or an ORDER BY clause, this is really useful, but the WHERE clause already allows you to use the IF-THEN-ELSE logic.

    However, if you use the BOX in a WHERE clause, it is as it does nowhere else.  Always BARGAIN instead of a single expression in a SQL data types.  All the clauses THEN (and ELSE, if there is one) must return a single expression, such as the NUMBER.  (There is no BOOLEAN data type in SQL).  So, you can use a CASE statement like this:

    ...

    CASES WHERE

    WHEN 1 = 1 THEN 1

    WHEN 1! = 1 THEN 2

    END = eid

    Here, the CASE expression takes the place of a NUMBER.

    However, if I was not sure if 1 = 1 or not, I would write the condition in this way, without a CASE expression:

    WHERE (1 = 1 AND eid = 1)

    OR (1! = 1 AND eid = 2).

  • Question of the CASE statement

    Is it OK to mix conditions inside the case statement? as for example:

    SUM (CASE WHEN b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245', '5345', '87894') THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    ???

    I put in parentheses between the two conditions?

    SUM (CASE WHEN (b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245 ', '5345', ' 87894')) THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    is this legal syntax? because its not complaining do not, but I want to just make sure that these things are good to use and the data comes right back.

    Thank you!

    Kodiak_Seattle wrote:
    Is it OK to mix conditions inside the case statement? as for example:

    SUM (CASE WHEN b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245', '5345', '87894') THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    ???

    Yes, you can do that. The conditions must be related somehow.

    I put in parentheses between the two conditions?

    SUM (CASE WHEN (b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245 ', '5345', ' 87894')) THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    You have no need, but if it helps you (or one who has to maintain the code) to understand it better, then go ahead. The cost can be one millisecond extra when the query is compiled (it will run everything as fast so be it), and the benefits can be enormous.

    I find that formatting code contributes much more clarity to have additional parentheses. Why not use something like that?

    SUM ( CASE
              WHEN (    b.SUPPLIER_NUM     = 12345
                AND  c.VPN           IN ('3245', '5345', '87894')
                )
          THEN a.TRAN_AMT
          ELSE 0
          END
        )          AS SUMSPEND_MOS
    

    If you have really complicated conditions, where you mix ANDS and ORs, then you should certainly use parentheses. It goes the same for the WHERE clause.

    is this legal syntax? because its not complaining do not, but I want to just make sure that these things are good to use and the data comes right back.

    The syntax is fine.
    If the data comes in good or bad is another matter. What data are, and what you mean by 'comes back good' (in other words, what results do you get off these data)?

  • How can I block a program that I have not loading when I start the computer. What is own mac. It comes to start scaning and ask to activate. Is this something authorized by apple. If this is not the case, how can I stop it from loading up.

    Recently whenever I start the computer a program named Mac cleaning charge, stat my scanning system and ask to activate. It looks like a third party program that I should pay. Is it an accredited program for mac. If this is not the case, how can block this load upward.

    Is it called Advanced Mac Cleaner?  If so go here. http://AMC.Kayako.com/Knowledgebase/article/view/4/0/how-to-uninstall-advanced-m ac-cleaner

    It is malware.

    Edit: See post of Linc Davis on this topic for more detailed information.

    Advanced Mac cleanser

  • problem of data flow in the case structures (using a state machine)

    Good day everyone.

    I'm having a problem with the flow of data between the structures of the case.

    I try to use an example of a state machine for this simple problem. but when I try to send data of a box structure to change the State of the code. It will change not in the desirable output, instead, it offers the possibility that the exit options emul.

    could someone please point what I'm doing wrong here. Any kind of help would be very appreciated.

    With a quick glance at your photos a question you have is that you use not data flow. You write your status updated in local variables value. Your State should pass through the case structures are a single wire. Playback of your order "Enum", happened in the register shift on the right side of your loop probably get running and reading before any processing occurs within the structure of your business. That's why you're reading the old value of the State and not the update. or have a classic case of a race condition in your code.

  • call the statement box inside the case statement

    I am writing a program which requires me to run a statement box inside another case statement. Although this sounds like a simple thing, I need to be able to call the case statement using a sequence structure, where s1 sends the true value to the case, s2, a fake. Then I need to record the results of this instruction box in a text file. Attatched is a simplified version of what I'm trying to do. Please note that the way my program runs may not call the case statement without using a sequence structure, two nesting box instructions is not feasible. I hope someone out there can help me because I was stuck trying to find this for awhile.

    Thank you

    LVStudent wrote:

    [...] I can't call the case statement without using a sequence structure

    Yes you can.  You just need to be smart.

    LVStudent wrote:

    I don't think I can use a state machine to fix this.

    I think you probably can.

    With respect to your original post. What are these s1 and s2 are you talking about?  My opinion on the matter, it is that you want to select a case based on the values of several controls Boolean.  If this is correct, I do this:

    Build your Boolean controls in a table, convert the table number and insert it into the structure of your business.  No button pressed = 0, s1 = only 1, s2 = only 2 both = 3.   This works for Boolean values as much as you want and is an easy way to make a decision that depends on many entries.

  • Structure of the case is not updated after changing type "enum".

    Hello

    After changing a type of 'enum', the structure of the case has not been last updated - it still contain 2 States, while after modificatiion, it must contain 4 cases.

    Is this a normal behavior?

    Thank you

    Pavel


  • Microsoft Backup does not seem to be the case at the scheduled time

    I put p Microsoft Backup to create an image of my hard disc, to run every day at 11:00, but when I looked right at him, under the "last backup" he said '' never. '' Why he would say this, I ran a manual backup a week or so, there is, as I feared him that my data was not backed up?

    I am now running a backup manually and would like to know how I can enter the backup on my drive hard dexternal to convince me that my files are up - t - date? It seems to be without directory tree.

    Hi Andrew,

     

    Thanks for posting your query in Microsoft Community.

    From your description, it seems the automatic backup doesn't seem to be the case at the scheduled time.

    I'll be happy to help you.

    I suggest to follow the steps below and we update on the State of the question.

    Method 1: Scan SFC Run in the computer

    Use the System File Checker tool to troubleshoot missing or corrupted on Windows Vista or Windows system files

    http://support.Microsoft.com/kb/929833

    Method 2: Check if the Volume shadow copy service and windows backup are running and set to automatic in the Services Console.

    a. click Start, type Services in Search. When the page is open, scroll down to find the shadow copy volume and Backup service.

    b. right click on them and see if they are started.

    c. If the services are disabled, start services and set it to Automatic and check if the problem is resolved.

     

    Method 3:

     

    Automatic backup of installation by following the steps in the link below:

    Set up or change automatic backup settings:

    http://Windows.Microsoft.com/is-is/Windows7/set-up-or-change-automatic-backup-settings

     

    Follow the steps in the link below to run the backup at the scheduled time.

     

    Schedule a task:

    http://Windows.Microsoft.com/en-us/Windows7/schedule-a-task

     

    For more information:

    Backup and restore: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows7/back-up-and-restore-frequently-asked-questions

    For all windows questions do not hesitate to contact us and we will be happy to help you.

  • Case statement does not work

    Dear all,

    We have the database oracle 11g r2 on windows.

    I created under function: -.

    SQL > CREATE OR REPLACE FUNCTION FUNC_TEST (P_TEST VARCHAR2)

    2 RETURN VARCHAR2

    3 AS

    4 V_TEST VARCHAR2 (20);

    5

    6 BEGIN

    7

    8 V_TEST: = P_TEST;

    9

    10

    11 CASES

    12. WHEN V_TEST = UPPER ('%UU%') THEN V_TEST: = REPLACE (V_TEST, 'UU', 'U');

    13. WHEN V_TEST = UPPER ('%OO%') THEN V_TEST: = REPLACE (V_TEST, 'OO', 'O');

    14. WHAT V_TEST = UPPER ('%NN%') THEN V_TEST: = REPLACE(V_TEST,'NN','N');

    15 ELSE V_TEST: = "CHANCHAL";

    END 16 CASES;

    17

    18

    19 V_TEST RETURN;

    20 EXCEPTION SO THAT OTHERS THEN

    21 DBMS_OUTPUT. PUT_LINE (' THERE IS AN ERROR ');

    22 END;

    23.

    The function is created.

    SQL > SHOW ERR

    No errors.

    SQL > SELECT FUNC_TEST('toon') FROM DUAL;

    FUNC_TEST ('TOON')

    --------------------------------------------------------------------------------

    CHANCHAL

    above function should show 'YOUR' build 'Toon' but its display "CHANCHAL";

    I train hard get the result OK but could not get it.

    Any suggestions would be very helpful.

    Kind regards
    Chanchal wankhade.

    Hello

    Chanchal Wankhade wrote:

    Dear all,

    We have the database oracle 11g r2 on windows.

    I created under function: -.

    SQL > CREATE OR REPLACE FUNCTION FUNC_TEST (P_TEST VARCHAR2)

    2 RETURN VARCHAR2

    3 AS

    4 V_TEST VARCHAR2 (20);

    5

    6 BEGIN

    7

    8 V_TEST: = P_TEST;

    9

    10

    11 CASES

    12. WHEN V_TEST = UPPER ('%UU%') THEN V_TEST: = REPLACE (V_TEST, 'UU', 'U');

    13. WHEN V_TEST = UPPER ('%OO%') THEN V_TEST: = REPLACE (V_TEST, 'OO', 'O');

    14. WHAT V_TEST = UPPER ('%NN%') THEN V_TEST: = REPLACE(V_TEST,'NN','N');

    15 ELSE V_TEST: = "CHANCHAL";

    END 16 CASES;

    17

    18

    19 V_TEST RETURN;

    20 EXCEPTION SO THAT OTHERS THEN

    21 DBMS_OUTPUT. PUT_LINE (' THERE IS AN ERROR ');

    22 END;

    23.

    The function is created.

    SQL > SHOW ERR

    No errors.

    SQL > SELECT FUNC_TEST('toon') FROM DUAL;

    FUNC_TEST ('TOON')

    --------------------------------------------------------------------------------

    CHANCHAL

    above function should show 'YOUR' build 'Toon' but its display "CHANCHAL";

    I train hard get the result OK but could not get it.

    Any suggestions would be very helpful.

    Kind regards
    Chanchal wankhade.

    I think you meant:

    CASE

    WHEN SUPERIOR (V_TEST) LIKE "% UU" THEN V_TEST: = REPLACE (UPPER (V_TEST), 'UU', 'U');

    WHEN SUPERIOR (V_TEST) LIKE '% OO %' THEN V_TEST: = REPLACE (UPPER (V_TEST), 'OO', 'O');

    ...

    '%' is a wildcard character only on the right-hand side of the LIKE operator. '%' has no particular meaning when you use the = operator.

    You can also use a CASE expression, rather than a CASE statement to this:

    v_test: = UPPER (p_test);

    v_test: = BOX

    WHEN v_test LIKE "% UU" THEN REPLACE (v_test, 'UU', 'U')

    WHEN v_test LIKE "% UU" THEN REPLACE (v_test, 'OO', 'o')

    ...

    END;

    Whatever it is, if v_test contains different models (for example "HOOVER VACUUM"), only 1 of them will be changed.  Is that what you want?

    If this isn't the case, after a few examples of data (CREATE TABLE and INSERT statements) and the results desired from these sample data.  Explain how you get these results from these data.

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • can we use alias name in the case statement?

    Select sal,

    Sal case

    When 500 then 'low '.

    When 5000 can 'high '.

    of another "medium".

    cases of termination

    EMP;

    OUTPUT

    case of SAL

    -----   --------

    4587 way

    5000 high

    .. .so I have worn instead of cases at the exit?

    Yes. Contrary to the statements of CASE in PL/SQL, SQL CASE expressions like this ends with 'end', not 'end of case. Your use of the terminal 'deal' was just an alias the column as the 'CASES '.

    select
      sal,
      case sal
        when 500 then 'low'
        when 5000 then 'high'
        else 'medium'
      end range
    from
      emp;
    
  • Understand the CASE statement

    I got confused on this CASE

    (1) SELECT BOX WHEN 111 = "111" THEN 'YES' ELSE ' ' END OF THE DOUBLE - YES

    (2) SELECT CASE WHEN COALESCE (111 111) DOESN'T = "111" THEN 'YES' ELSE ' ' END OF THE DOUBLE - YES

    (3) SELECT CASE WHEN COALESCE (111, '111') = '111' THEN 'YES' IS ' ' END OF THE DOUBLE

    ORA-00932: inconsistent data types: expected NUMBER obtained TANK

    What exactly the things happening between 2 & 3. ' nt it implicitly convert as case 2 is because that in case 3, the first value is anyway not null as CAS2... This leads to confusion.

    I have read the Oracle documentation and there is an implicit data type conversion table. It also indicates that can be converted. There is always some confusion raised. Anyone could wrap this confusion?

    No, the function coalesce requires that all entries to be of the same data type because they are arguments of this function.

    Conversion of implicit data type occurs generally when things are compared with operators (as you do in examples 1 and 2.

    There is not many functions/procedures of this nature that the mixed data types and convert them for you.

    So, it is nothing to do with the CASE statements, it's in with him COALESCE function.  It is overloaded for particular data types, but it requires all arguments to be of the same data type.

  • doubt in the case when statement

    Hi the gems...

    I have a case when statement in a select clause... ago total three conditions in the case when statemnt.

    now my question is if all theconditions gets mapped, what happens?

    is only the first condition is executed and rest two is ignored or the third condition will overwrite the previous two?

    Please help... Thanks in advance...

    You can see it with:

    select case when 1=1 then 1
                when 2=2 then 2
                when 3=3 then 3
           end test
    from dual;
    
    TEST
    ---------
    1
    

    You get only the first result!

    Published by: hm on 18.11.2011 04:11

Maybe you are looking for