Sql case is null db2
If we supply all the parameters as NULL, then it gives out no error without any output. The ISNULL function will go for searching the first non-NULL value; if the column has any date stored in it, then it displays that date else, it goes further to replace that null value stored in the column with the value specified in the second parameter.
The output of the above query statement is shown below with replacing the values of the purchase date column with null values with the date that we have specified in the last value retrieved in the select query. We can also make the use of the ISNULL function to replace the column value having NULL in it with some other column value by specifying the column containing NULL values as the first argument and the column with which the value needs to be replaced in the second argument.
Consider an example where we have the table named workers created by using the following query statement. Using the following query statement, we can display the column address2 value in address1 place if it is NULL, as shown below.
You don't need trim if you are checking for NULL values. So, consider something like:. Your question is actually why you are getting that error. Well, basically it is listing some possible tokens that can appear between the '' and whatever comes next. Also, you don't need the trim function.
Plus, this assumes your field is char or varchar. If it's a date, you can't use trim. Also, make sure your default value is a valid date in db2. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. When date is Null return another value? Asked 6 years ago. Is there any other alternatives? Eray Balkanli 7, 10 10 gold badges 42 42 silver badges 71 71 bronze badges. VladP VladP 2 2 gold badges 10 10 silver badges 30 30 bronze badges.
Add a comment. Active Oldest Votes. Gordon Linoff Gordon Linoff 1. Federico Razzoli Federico Razzoli 4, 1 1 gold badge 18 18 silver badges 20 20 bronze badges.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science.
0コメント