I have a query that has a datetime field and now I need to have a union that will retrieve data from some other tables but for the datetime field in the union, I want the results to have that field empty.
I'm sorry that I don't quite understand all of the issues in your post. In the UNION query:[ul][li]Do you have control over all of the code, including the original portion of the query? (i.e., can the original query change?)[/li][li]If the field will be empty anyway, do you even want the column to appear on output?[/li][li]If a row from the existing query matches (except for the DATETIME) a row coming from another table in the UNION query, do you want the matching row to display?[/li][/ul]
Thanks,
Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
Does the second table in the UNION also have a datetime field or is the problem that this field is missing and you want to substitute a null value for it ?
If the latter, you can do something like:
select
tabdate
from table1
union
select to_date(null) as tabdate
from table2
A view was created for us (the person that created the view is no longer here) that includes a datetime field but some data isn't being retrieved in the query.
I thought I would add a union in the query (there is a table with a datetime field in the union but it isn't the right datetime field) and just leave the union's datetime field empty (the user would then just have to look up the datetime for the ones in the union since there is only a few records). Example:
Duh, I have it working. I just outer joined the view and used that datetime field and since the data isn't in the view, the datetime field was blank for the union. Thanks.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.