oracle - Searching first condition first and only if not available then second condition -
i writing sql query query should first search first value, , if value missing query should search second value.
i have 2 tables. 1 of these tables contains modification date (this not filled , can null
) , creation date filled.
now want query first looks in table modification date , if null
looks @ table creation date.
example of query:
select * all_articles to_char(modification_date, 'yyyymmdd') = to_char(sysdate, 'yyyymmdd')-1 -- if empty record to_char(creation_date, 'yyyymmdd') = to_char(sysdate, 'yyyymmdd')-1
can me query?
almost major rdbms' available have in built functions handle such situation. oracle db has nvl function works follows: nvl(modified_dt, create_dt);
the above return modified_dt column data default. however, if isn't available, return create_dt.
see here details: http://www.w3schools.com/sql/sql_isnull.asp
Comments
Post a Comment