Introduction to common DB2 functions 1. VALUE Function Syntax: VALUE (EXPRESSION1, EXPRESSION2) the VALUE function returns a non-empty VALUE. When the first parameter is not empty, the VALUE of this parameter is directly returned, if the first parameter is null, the value of the first parameter is returned.
Java code eg: -- indicates that if T1.ID is null, an empty string is returned. If T1.ID is not empty, T1.ID is returned. Select value (ID, '') FROM T1 www.2cto.com 2. DATE functions SQL Server stores DATE or DATE/time values in a database using the following data types: DATE-format YYYY-MM-DDDATETIME-format: YYYY-MM-DD HH: MM: SSSMALLDATETIME-format: YYYY-MM-DD HH: MM: SS
TIMESTAMP-format: A unique number. If the time part is not involved, we can easily compare two dates! Suppose we have the following "Orders" table: www.2cto.com OrderId ProductName OrderDate1 computer 2008-12-262 printer 2008-12-263 electrograph 2008-11-124 telephone 2008-10-19OrderId ProductName OrderDate 1 computer 2 printer 3 electrograph 4 telephone now, we want to select a record whose OrderDate is "" from the preceding table. We use the following SELECT statement: Java code SELECT * FROM Orders WHERE OrderDate = '2017-12-26 'can extract two records. If orderdate is 16:23:55 (in timestamp format), the above statement cannot be used to query our results. This is because the query does not include the date with time. Therefore, you need to rewrite the statement to: Java code SELECT * FROM Orders WHERE (date) orderDate = '2017-12-26 'www.2cto.com OrderId ProductName OrderDate1 computer 2008-12-2008 electrograph OrderId ProductName OrderDate1 computer 263-12-2008 electrograph