Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    9

    Unanswered: how to make a date field null in a union

    Hi,

    I use a union statement something like this,

    select f1,date1,f2 from T1
    union
    select g1,date2,g2 from T2

    where both date1, date2 are TIMESTAMP fields and NULLable.
    How to make date1 field null in the above SQL?
    I have tried things like NULL date1,'NULL' date1.
    but it doesn't work.

    Can someone help me out of this?
    Thanks,
    K Rajkumar

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: how to make a date field null in a union

    Use the CAST Fuction

    select f1,CAST(NULL AS DATE) date1,f2 from t1
    union
    select g1,date2,g2 from T2




    Originally posted by krajkumar6
    Hi,

    I use a union statement something like this,

    select f1,date1,f2 from T1
    union
    select g1,date2,g2 from T2

    where both date1, date2 are TIMESTAMP fields and NULLable.
    How to make date1 field null in the above SQL?
    I have tried things like NULL date1,'NULL' date1.
    but it doesn't work.

    Can someone help me out of this?
    Thanks,
    K Rajkumar
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    or just do them in the other order --

    select g1,date2,g2 from T2
    union
    select f1,null,f2 from T1




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •