How to write a select statement inside the case operator

Hi all

I want to write a query that get the result of another table of case operator.

for example

Select a, b, c of the double
where a = 1
and b = case when b is null then 'select any value from the other table' any other purpose;


Please help me to write this query.

Thank you

Select a, b, c of the double
where a = 1
and b = case when b is null then 'select any value from the other table' any other purpose;

Guilty plea

Select a, b, c from tableA a
where a.a = 1
and a.b = (select decode (a.b, null, (select 1 from tableB b where rownum = 1), a.b) double)

Tags: Database

Similar Questions

  • How to convert this select statement in the update

    Hai All

    I have two tables namely Daily_attend, Train_mast

    The Daily_attend are made up of fields are Train_mast are made up of fields are

    Name varchar form no var

    Date of empcode Num V_DATE

    Intimate Date Train_name var

    Outtime date Late_hrs var

    Number IND_IN

    Number IDE_OUT

    Date of Attend_date


    I need to update the table Depend of IDE_IN in Daily_attend in late_hrs in the Train_mast table

    I got through in the select statement, it is my select statement

    Select to_number (TO_DATE (TO_CHAR(Intime,'DD-MON-YYYY') |)) » '||
    To_char (0815, '0000'), 'MON-DD-YYYY HH24') + late_hrs /(24*60)-respondent
    ) * 24 * 60 dail_Att, train_mast;

    How can I convert to update

    Any help is highly appricateable

    Thanks in advance

    Concerning

    Srikkanth.M

    Srikkanth,

    Try this code. And 1 thing, I don't see any WHERE condition to join between the 2 tables, DAIL_ATT, TRAIN_MAST.

    UPDATE DAIL_ATT A SET A.IDE_IN = (SELECT TO_NUMBER(TO_DATE(TO_CHAR(INTIME, 'DD-MON-YYYY')|| ' ' || TO_CHAR(0815, '0000'), 'DD-MON-YYYY HH24:MI') + LATE_HRS / (24 * 60) - INTIME) * 24 * 60 FROM TRAIN_MAST B WHERE );
    

    Kind regards

    Manu.

    If my answer or the answer to another person has been useful or appropriate, please mark accordingly

  • How to write a select statement in which the condition?

    Hello Frs,

    Need help in the development of a discoverer report.

    My requirement is to write a query similar to this one

    Select * from emp is dept_no not in (select Department dept_no where emp_name like ' a % ;))

    Help, please.


    Thank you
    Rajesh

    Hello
    to do this exactly how you can do 1 of 3 things:
    1 use the Discoverer Desktop edition (most didn't do it) and use the sub query option you will find in the conditions.
    2. create a custom in the BA folder and create the report on the new custom folder
    3. create a view of db that contain your selection, and then create a folder in the BA based on this point of view and then create your report.

    Tamir

  • By using the parameter as a column in a select statement inside the stored procedure.

    I'm doing a variation of what follows. Can someone tell me how to use the parameter passed in the IN clause correctly? Thank you
    drop table test1;
    drop table test2;
    
    CREATE TABLE TEST1
    (
      COL1  NUMBER
    );
    
    CREATE TABLE TEST2
    (
      COL2  NUMBER
    );
    
    insert into test1 values (1);
    insert into test2 values (1);
    
    commit;
    
    create or replace  procedure test_sp (col_name varchar2)
    as
    
    var1 number;
    begin
    
    select col1 into  var1 from test1 where col1 in (select col_name from test2);
    
    end;
    
    exec test_sp ('COL2');
    Deleted table.
    Deleted table.
    Table created.
    Table created.
    1 line of creation.
    1 line of creation.
    Validation complete.
    Created procedure.
    BEGIN test_sp ("COL2"); END;
    Error on line 29
    ORA-01722: invalid number
    ORA-06512: on-site ".» TEST_SP', line 7
    ORA-06512: at line 1

    You must use dynamic sql statements:

    SQL> drop table test1;
    
    Table dropped.
    
    SQL> drop table test2;
    
    Table dropped.
    
    SQL> CREATE TABLE TEST1
      2  (
      3    COL1  NUMBER
      4  );
    
    Table created.
    
    SQL> CREATE TABLE TEST2
      2  (
      3    COL2  NUMBER
      4  );
    
    Table created.
    
    SQL> insert into test1 values (1);
    
    1 row created.
    
    SQL> insert into test2 values (1);
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> create or replace  procedure test_sp (col_name varchar2)
      2  as
      3  var1 number;
      4  begin
      5  execute immediate 'select col1 from test1 where col1 in (select ' || col_name || ' from test2)' into var1;
      6  end;
      7  /
    
    Procedure created.
    
    SQL> exec test_sp ('COL2');
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • How to write a GREP statement in the section of "GREPStyle" of a definition by script?

    Hello

    I need to do a GREP Style, based on the character Style in some paragraph Styles by the script, but I don't know how?

    I can't find apropriate method or property in the DOM?

    Is this possible?

    Best regards

    Marcin

    Hello

    If

    cPara - is your definition of the target;

    cChar - is characterStyle you want to apply

    cExpression - is a string containing the GREP expression

    use:

    cPara.nestedGrepStyles.add({
        appliedCharacterStyle:cChar,
        grepExpression:cExpression
         });
    

    Jarek

  • How to create a select statement to the data in two tables?


    Hi all

    Table 1

    ID YEAR

    758 2013

    Table 2

    ID YEAR

    758 2014

    I want to create some that translates into two lines: function that does this?

    ID YEAR

    758 2014

    758 2013

    Thank you, best regards.

    Hello

    Perhaps a select * from table1 UNION ALL select * from table2 will help you.

    concerning
    Kay

  • How to block a select statement for a table of the specified until validation line

    Hello

    How to block a SELECT statement for a specified row in a table until willingness to engage occure?

    My procedure is part of a Stock request and if a user (X) get stock 1 piece, another user must wait for the user (Y) complete his reportoire.

    So, let say my stock have 10 pencils.

    When the X user starts the Stock_PLS procedure, in table Stock, line (e.g. R1) that user X should work with it, must be lock up to what the commit / rollback will appear.

    procedure Stock_PLS...

    Start
    ..
    pencils: pencils-1 =;
    ..
    End

    Observation-> pencils: = 9;


    This means that is a user there, run SELECT * stock of the table where rows_id = R1, SELECTION should wait the Stock_PLS started by user X will be completed (with commit or rollback) and his SELECT should return the value 9.

    What I need, is that Oracle has something like LINE EXCLUSIVE TABLE LOCK, but in my situation the SELECT statement should be denied on the specified lines, until the end of the procedure.

    Kind regards
    Michael

    Hello
    You can achieve this using the update with the Select clause.
    You can write your select statement like this
    SELECT * from stock of the table where rows_id = R1 for update;

  • to find the number of records retrieved in the select statement in the cursor

    Hi all
    with the cursor, I'm selecting select statement together and writing in the .txt file.
    his worksheet, but it should not open the file, if the cursor returns nothing.
    How to find the number of records returned by the select statement in the cursor.
    pls help me.

    Thank you...

    Don't understand what you're trying to say, but maybe it's...

    DECLARE
       vCounter NUMBER;
       -- Other variables...
    BEGIN
       vCounter:=0;
       FOR .. IN cursor LOOP
        IF vCounter=0 THEN
          -- Here open file...
          -- Here write one time data...
        END IF;
        -- Here write cursor data...
        vCounter:=1;
       END LOOP;
    END;
    

    -Clément

  • Decode the statement inside the box

    Can we use Decode statement inside a CASE statement as below - show

    It gives an error - the better to write with any error

    create or replace
    test run (a varchar2) RETURN VARCHAR2
    is
    m varchar2 (20);
    Start
    m : =
    CASE
    WHEN a (IN)
    '1009 '-(soon obsolete)
    "1010"
    , ' 1019 "
    '1051'
    , "XGP.
    "XSC")
    (SELECT DECODE(v_lef_cd,'NAM','71','GLB','99','01') in the of THE DOUBLE m)
    (-) THEN '01' - UNITED STATES
    WHEN a (IN)
    ' 1069' - South Africa
    , "SAO" - South Africa
    , 'HIS' - South Africa
    ) THEN '26' - South Africa

    ANOTHER NULL
    END;
    return m;
    end;

    Hello

    user575932 wrote:
    Thanks for your reply... I would be happy if my problem is completely resolved

    In the code below in the ELSE part... (When the value NULL is written) I have check for more condition using IF/ELSE or DECODE...

    SQL > l
    1 DECLARE
    v_var1 2 VARCHAR2 (20);
    3 model VARCHAR2 (20): = 'X '.
    4 BEGIN
    v_var1 5: = dummy BOX WHEN ('X', 'y')
    6 THEN CASE model WHEN = 'X' THEN 'HELLO WORLD '.
    7. OTHER SIDE (_ NULL);
    8 DBMS_OUTPUT. Put_line (v_var1);
    9 END;
    10.

    Sorry, it's impossible. You cannot place the executable statements in PL/SQL (as IF...) ELSE or SELECT... INTO) in the middle of the CASE expression.

    You can get some desired using the results
    (1) IF... Else constantly, instead of CASE (this would allow you to do a SELECT... If you really want to use DECODE INTO), or
    (2) nested CASE expressions, as I showed above, or by
    (3) reformulating the expression BOX so it shouldn't be a nested DECODE or CASE, as I showed earlier

  • How to write a function to estimate the number of rows returned SQL?

    How to write a function to estimate the number of rows returned SQL through SQL Execution Plan?
    My idea is
    Call dbms_sql.parse to create the SQL PLAN, then ask the PLAN for the number of estimated return lines.
    But how to get SQL plan through "id cursor?
    Thank you.

    You can use EXECUTE IMMEDIATE to explain plan statement. About the STATEMENT_ID generation, it could be anything. Even a SYSTIMESTAMP cast as TANK would work.

  • Does anyone know of a VI or how to write one that will stop the computers time be disabled if an application is run.

    Does anyone know of a VI or how to write one that will stop the computers clock be turned off if an application is run. The time and date can be reset normally while an application is running by clicking on the time in the lower right of the screen of the computer. I have an application that runs over several days and it is essential that the time and date of the computer not be changed. Is there an easy way of this lockout the user? Note that I am what I consider a beginner advanced in LV

    Thank you

    Chuck

    This isn't something that you can from LabVIEW, because this is an operating system operation, and it will depend on the operating system you are using. Under Windows, you can use Group Policy to control this. Please Google on "prevent changing the date and time of windows."

    Also, please try to refrain from stuffing your message in its entirety in the block of material. Keep short, but descriptive enough topic so we can understand what you're asking basically. Thank you.

  • SELECT statement in the script output window

    Hello

    SQL Dev 4.0.3

    is it possible to include select statements from the command run the Script in the Script Output window?

    Is the result in the window:

    Select 1... ;

    results

    Select 2... ;

    results

    Joop

    try to put "set echo on" (without the quotes) as the first line and make sure that you use F5 to run the script... like sqlplus.

  • I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content

    Hello

    Can the code below is useful for you, but I do not know how to sort.

    Change the tag based on your employment application.

  • How to get a select statement to pass a variable as the OUT parameter in PROC

    I have the underside of the nested select statement that returns the name of the missing table (data_table_name).

    How to be an effective way to modify the select statement, so that the returned 'data_table_name' is passed as OUTPUT in a procedure parameter
    select 'Missing Table Name : ' || data_table_name
         from   ( select upper(data_table_name) data_table_name
                  from   TABLE1
                  where  data_table_name in ('ABC',EFG','XYZ')
                MINUS
              ( select upper(fus_data_table_name)
                from   TABLE2
                where  fus_data_table_name in ('EFG',')
              group by
                     upper(fus_data_table_name)
              union
              select upper(fus_data_table_name)
              from   TABLE2
              where  fus_data_table_name = 'LMN'
              group  by
                     upper(fus_data_table_name)
            ));
    Any help is greatly appreciated.

    S
    CREATE OR REPLACE PROCEDURE myproc (tname OUT NOCOPY VARCHAR2) AUTHID CURRENT_USER IS
    BEGIN
      SELECT something
      INTO tname
      FROM whatever;
    EXCEPTION
      WHEN OTHERS THEN
        tname := ;
    END myproc;
    /
    
  • How to write Save function based on the drop-down list box selection data in app mxml flex4 with as3

    Hi all

    I'm working on the application web flex4 with as3.

    I have a doubt, I've created a mxml it has two text boxes, except the button and a combo box that is has two option as a percentage and the amount.

    my needs are I gave here.

    need 1: when I choose option amount that two text boxes does not have to be editable.when I select text tat box two percentage option will be editable.

    need 2: when I select the percentage in combox option and two text boxes are empty, and then click the button Save-> I want to display warning msg

    need 3: when I select the option amount combox and the two boxes are emptu click the button Save-> I don't want any warning messages.

    How to validate it and how to write backup for this function.

    This is my sample code:

    list box ID = baseAmtPer

    ID TextBox1 = maxCommAmt.text

    ID = baseAmtPer.text text box

    If (((baseAmtPer.editable!=true) & & (maxCommAmt.editable! = true)) & & ((baseAmtPer.text=="") & &(ma xCommAmt.text=="")) |) (baseAmtPer.text == "") | (maxCommAmt.Text=="")) -> This condition not allowing while I'm selecing amount in combo box. How the TWO TEXT BOX WILL BE EMPTY for this problem

    {

    Alert.Show ("enter in all areas", "Information");

    }

    on the other

    {

    some encodings

    }

    Hello

    Please go through the following Code:

    http://ns.Adobe.com/MXML/2009.

    xmlns:s = "library://ns.adobe.com/flex/spark".

    xmlns:MX = "library://ns.adobe.com/flex/mx" minWidth = "955" = "600" minHeight >

    Import mx.collections.ArrayCollection;

    Import mx.controls.Alert;

    Import spark.events.IndexChangeEvent;

    protected function button1_clickHandler(event:MouseEvent):void

    {

    If (comboBox.selectedItem == "Percentage" & textBox1.text == "" & textBox2.text == "") {}

    Alert.Show ("enter the values");

    }

    }

    protected function comboBox_changeHandler(event:IndexChangeEvent):void

    {

    {if(ComboBox.SelectedItem=="Amount")}

    textBox1.editable = false;

    textBox2.editable = false;

    }

    else {if(comboBox.selectedItem=="Percentage")

    textBox1.editable = true;

    textBox2.editable = true;

    }

    }

    ]]>

    Amount

    Percentage

    Thank you and best regards,

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

    Vibhuti Gosavi . [email protected] | www.infocepts.com

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

Maybe you are looking for