Set Operators - Clarification needed

This is my query. I am executing this in HR Schema Oracle 11g.
SELECT HIRE_DATE, EMPLOYEE_ID, to_char(null) FROM EMPLOYEES WHERE LAST_NAME='Taylor'
UNION ALL
SELECT SYSDATE, TO_CHAR(NULL), 1+1 FROM DUALIt gives ORA-01790: expression must have same datatype as corresponding expression error. What data type is mismatching here? I don't seem to understand. HIRE_DATE and SYSDATE - DATE data type. Is something wring with my other two columns? I read that TO_CHAR(NULL) can be used for filling missing values. That's why I tried this way.
Any guidance, please?

Hi,
whenever you use set operators there has to be ont to one datatype correspondance of the columns you define in all the select statements.
Here the first select statement's employee_id number is conflicting with to_char(null) and to_char(null) is conflicting with 1+1.
Hence try out this
SELECT HIREDATE, Empno, to_char(null) FROM EMP WHERE ename='Taylor'
UNION ALL
SELECT SYSDATE, 1+1,TO_CHAR(NULL) FROM DUAL
or use
SELECT HIRE_DATE, EMPLOYEE_ID, to_NUMBER(null) FROM EMPLOYEE WHERE LAST_NAME='Taylor'
UNION ALL
SELECT SYSDATE, TO_NUMBER(NULL), 1+1 FROM DUAL

Similar Messages

  • Set operators over ore.frame

    Is there a way to make set operators work with ore.objects without ore.pull?
    EXAMPLE:
    > df1 <- data.frame(ID=c(1:3),A=rep(1,3))
    > df2 <- data.frame(ID=c(2:4),B=rep(1,3))
    > class(df1)
    [1] "data.frame"
    > # Union
    > union(df1$ID,df2$ID)
    [1] 1 2 3 4
    > # Minus
    > setdiff(df1$ID,df2$ID)
    [1] 1
    > #Intersect
    > intersect(df1$ID,df2$ID)
    [1] 2 3
    > #-------------------------------------------------
    > of1 <- ore.push(df1)
    > of2 <- ore.push(df2)
    > class(of1)
    [1] "ore.frame"
    attr(,"package")
    [1] "OREbase"
    > # Union
    > union(of1$ID,of2$ID)
    integer(0)
    > # Minus
    > setdiff(of1$ID,of2$ID)
    integer(0)
    > #Intersect
    > intersect(of1$ID,of2$ID)
    integer(0)
    > #-------------------------------------------------
    > vec1 <- ore.push(df1$ID)
    > vec2 <- ore.push(df2$ID)
    > class(vec1)
    [1] "ore.integer"
    attr(,"package")
    [1] "OREbase"
    > union(vec1,vec2)
    integer(0)

    Many of the commonly used base R functions are overloaded in the Oracle R Enterprise transparency layer to work with ore.frame objects.  These functions are located in the OREbase and OREstats packages.
    For example, to get the union, use merge, as it has been overloaded to operate on ore.frame objects:
    R> find("merge")
    [1] "package:OREbase" "package:base"  
    merge(x = of1, y = df2, all = TRUE)
    R> merge(x = of1, y = of2, all = TRUE)
    ID  A  B
    1|NA  1  1 NA
    2|1   2  1  1
    3|2   3  1  1
    NA|3  4 NA  1
    to subtract:
    R> find("Arith")
    [1] "package:OREbase" "package:methods"
    of1$A - of2$B
    R> of1$A - of2$B
    [1] 0 0 0
    There is no need to pull the data if the function is overloaded to work with ore.frame objects.  More examples can be found in the ORE 1.4 Training Materials: Oracle R Enterprise 1.4 Transparency Layer: http://www.oracle.com/technetwork/database/database-technologies/r/r-enterprise/learnmore/ore-1-4-transparency-layer-215…
    You can view the functions in the OREbase and OREstats packages by typing:
    ls("package:OREbase")
    ls("package:OREstats")
    Sherry

  • SELECTing records from two tables. Set Operators, CASE, DECODE, ...

    Hi all,
    I have two tables:
    CRETE TABLE T1 (T1_COL1 NUMBER, T1_COL2 NUMBER)
    CRETE TABLE T2 (T2_COL1 NUMBER, T2_COL2 NUMBER)
    T1 may or may not have records. T2 always has records. There are two scenarios.
    Scenario 1:
    =======
    SELECT * FROM T1 returns five rows, and SELECT * FROM T2 returns 10 rows.
    Now I need the five rows from T1.
    Scenario 2:
    =======
    SELECT * FROM T1 returns zero rows, and SELECT * FROM T2 returns 10 rows.
    Now I need the 10 rows from T2.
    In other words, if records present in T1, I need them all. If not, I need records from T2.
    There are no common columns (for joins).
    Now need a single query to achive this. I tried set operators, CASE and DECODE. But I'm unable to solve it.
    Please help. Thanks in advance.

    Iniyavan wrote:
    Yes, Justin. I'm sure that this is the way it's modelled. I also find it's tough and odd.Are you sure it's the right way for that data to be modeled? I understand that's the way it is being modeled, but a data model change may be the best option.
    Is there any other way, which is simpler, without using RANK?That's the simplest option I can think of. You could also do something like
    SELECT t1_col1, t1_col2
      FROM (
        SELECT t1_col1, t1_col2, rownum rn
          FROM (
            SELECT t1_col1, t1_col2
              FROM (
                SELECT t1_col1, t1_col2, 1 tbl
                  FROM t1
                UNION ALL
                SELECT t2_col2, t2_col2, 2 tbl
                  FROM t2       
             ORDER BY tbl
    WHERE rn = 1I'm not sure that's any simpler...
    Justin

  • Question about email setting: how  do i change the setting so i need to login to check my email. Currently it automatically come to the inbox without the need to log in. Thanks

    Question about email setting: how  do i change the setting so i need to login to check my email. Currently it automatically come to the inbox without the need to log in.

    You don't. Email comes in either by push or when you invoke the email app. Ther is no password except when you first set up the account. If your iPad is not being used as your personal device and you need to shield emails from other users, then don't use the email app.  Instead, use web mail if available from your provider.

  • HT204053 How do you change apple id for icloud if phone is already set up. Need to give each phone in my account their own apple id for icloud so that we dont receive each others messages but can still all use same id for purchases.

    How do you change apple id for icloud if phone is already set up. Need to give each phone in my account their own apple id for icloud so that we dont receive each others messages but can still all use same id for purchases.

    Settings-icloud-scroll to the bottom, select delete, if you want to keep the content select keep, otherwise it'll remove it. Then once it is done add the account information for the account you want on that phone.  Your apple ID in settings-store will remain the same and each device can still purchase/use content from that account.

  • What is use of set operators in OBIEE

    Hi Guys,
    Colud you please tell me what is main use of Set Operators (Intersection,Union,Union all)in OBIEE.
    Is it mandatory to use them in reports?
    Pls tell me.
    Regards,
    siva

    Hi,
    What scenario we are using set operators.
    For Eg.
    Col 1 is having values:
    A
    B
    C
    Col 2 is having values:
    1
    2
    3
    I have to create a new column in answers having values
    A
    B
    C
    1
    2
    3
    solution:
    You can use SET operators in OBIEE and it's really easy to set it in answers section. So create one request and then add other similar request to it by using UNION operator.
    or
    we can use case statement also.
    2. Is it mandatory to use them in reports?
    Normal reports not mandatory.
    Hope it helps.
    Thanks,
    satya

  • What setting do I need to change to have a search result file (pdf. or whatever) open instead of automatically download?

    Firefox downloads files automatically when opening a opening a search result. What setting do I need to change to have the search result file (pdf. or whatever) open instead? Something changed yesterday and I lost the ability to open the files vs. download.
    == This happened ==
    Every time Firefox opened
    == July 7, 2010

    Hello,
    Normally, when I use my online account, when i select a document to open with excel or with adobe, the applicaiton installed on the PC, is used to open the files.
    Can you check the under control panel, default programs, and see what program  is associated to the PDF files?
    When you try to open one of those pdf files from your back, what happens?
    If you download them to the HDD, are they automatically associated to ADOBE?
    Thanks,
    I work for HP! Please remember to provide and if this helped click ON

  • What setting do i need to set up airprint

    what setting do i need to set up airprint

    there's not really any set up to do. you have to be on the same network as an airprint enabled printer, then tap the arrow at the bottom of your screen and hit print, your phone will search for available printers and that's it.

  • Creating measure using set operators in BO Xi 3.0

    Hi All,
    I am trying to create a measure like this in BO XI 3.0 Designer.
    Select count(*) from
    select id from table1 where Name=<Prompt Value>
    INTERSECT
    select id from table1 where Name=<Prompt Value>
    But I don't know how to use set operators in Designer.
    Can someone please help or any pointer would help.
    Thanks,
    Kuldeep
    Edited by: Kuldeep Chitrakar on Apr 2, 2009 4:06 PM

    Create a derived table with same SQL and drag the table into universe pane to create object.

  • Set operators in PLSQL

    Hi All,
    Can we use set operators in PLSQL. I hope we can not use it in PLSQL. But just wanted to check with you all.
    Begin
    select 1 into n from dual
    union
    select 2 into n from dual;
    end;
    Thanks

    Not using that syntax you won't in PL/SQL as it's just wrong.
    As you're querying multiple rows you'd have to either loop or collect it in to a collection e.g.
    SQL> declare
      2    type aNums is table of number;
      3    vNums aNums;
      4  Begin
      5    select n
      6      bulk collect into vNums
      7    from
      8      (
      9      select 1 as n from dual
    10      union
    11      select 2 from dual
    12      );
    13  end;
    14  /
    PL/SQL procedure successfully completed.
    But yes, you can use any SQL statements in SQL that you use in PL/SQL.

  • Suddenly, I am unable to follow a link in my Email.  What setting do I need to change to be able to do this again?

    I am unable to follow a link in my Email.  I had been doing this.  I cannot find which setting needs to be changed so that I can follow a link in an Email.  What setting do I need to change to be able to follow an imbedded link?

    Have you tried restarting or resetting your iPad?
    Restart: Press On/Off button until the Slide to Power Off slider appears, select Slide to Power Off and, after It shuts down, press the On/Off button until the Apple logo appears.
    Reset: Press the Home and On/Off buttons at the same time and hold them until the Apple logo appears (about 10 seconds).

  • HT1689 Some of my email addresses don't make it to my iPhone after being delivered to Outlook.  Is there a setting that I need to change on either Outlook or my iPhone?

    Some of my email messages don't make it to my iPhone after being delivered to Outlook.  Is there a setting that I need to change on either Outlook or my iPhone?

    Unable to make or receive FaceTime calls after April 16, 2014

  • When typing email address that I have sent emails to before what setting do I need to change so my computer will remember these email addresses, like explore does? I can't find my email settings?

    When typing email address that I have sent emails to before what setting do I need to change so my computer will remember these email addresses, like explore does? I can't find my email settings?

    This is called autocomplete. Please read the article [[Form autocomplete entries are not saved]], as it should solve the problem.

  • HT4759 My "notes" made on phone disappear on charging phone using apple computer and not found on iCloud either...what setting do I need to adjust?

    My "notes" made on phone disappear on charging phone using apple computer and not found on iCloud either...what setting do I need to adjust?

    You got it.
    Notes - if notes are created in icloud notes (you may have multiple notes accounts) - icloud notes and only icloud are synced over all your devices and icloud server, so if you want to see those on the server you can go and manage (edit) on www.icloud.com.
    Since notes synchronize by using same IMAP email server - turning them "ON" will prompt you to create mail address.
    To add to that you do not have 10.8 that has it's own notes app, so your notes go to Notes folder in your icloud/me/mac mail and synched by your mail server.

  • I am trying to open a video in a website and it says, "This video is unavailable in safe mode"  What setting do I need to change and how do I do that?  Thanks

    Apple OSX version 10.9.5
    Processor 2.7 GHz Intel Core i5
    I am trying to open a video in a website and it says, "This video is unavailable in safe mode"  What setting do I need to change and how do I do that?  Thanks

    https://support.google.com/youtube/answer/174084?hl=en

Maybe you are looking for