DB2 the natural days of the specified interval

Source: Internet
Author: User
Tags db2

Oracle

(Select to_char (A+1-id, ' YYYYMMDD ') Show_time from (

SELECT rownum id,to_date (#{enddate,jdbctype=varchar}, ' YYYYMMDD ') A from DUAL

CONNECT by Level <= to_date (#{enddate,jdbctype=varchar}, ' YYYYMMDD ')-To_date (#{startdate,jdbctype=varchar}, ' YYYYMMDD ') + 1) Order by Show_time) d left JOIN TableA


DB2:

--Take the natural days of the specified interval

With Date_list (Show_time) as

(Select To_date (#{startdate,jdbctype=varchar}, ' YYYYMMDD ')

From Test.tablea a Where A.user_id=#{userid,jdbctype=varchar}

UNION ALL

Select Date_list. Show_time+1 Day

From Test.tablea B, date_list where B.user_id=#{userid,jdbctype=varchar} and date_list. Show_time <= to_date (#{enddate,jdbctype=varchar}, ' YYYYMMDD ')),

--Statistical transactions

Trans_list (Transdate,txncount,txnamt) as

(SELECT ...)

--External connection Get transaction statistics

SELECT * from Date_list D left JOIN trans_list E


DB2 the natural days of the specified interval

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.