Search code examples
sqldummy-variable

Dummy DATE field with NULL value


I am performing a union between two tables. In order to make the two tables consistent for a UNION, I need to add a dummy column.

One table has DATE field whereas the other table does not have that field. How can I create the dummy DATE field which can either be '' (blank) or NULL?

I am trying something like this in DB2

TO_DATE('','MM/DD/YYYY') AS DUMMY_DATE


Solution

  • Just select null.

    select col1, datecol from table1
    union all
    select col1, null from table2