Introduction to common DB2 Functions

Source: Internet
Author: User
Tags db2 functions


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.