Data per day in oracle statistical period (recommended), oracle per day

Source: Internet
Author: User

Data per day in oracle statistical period (recommended), oracle per day

The following describes the data of each day in the oracle statistical period. The specific SQL statement is as follows:

1. generate 1000 RANDOM numbers select rownum rn, DBMS_RANDOM.VALUE (0, 1000) random from dual connect by rownum <= 1000; Note: DBMS_RANDOM.VALUE (A, B) is A RANDOM number generation function, A is the start of the interval, and B is the end of the interval. 2. for example, to split A, B, C, and D strings separated by commas (,), SELECT REGEXP_SUBSTR ('a, B, C, D', '[^,] +', 1, ROWNUM) from dual connect by rownum <= REGEXP_COUNT ('a, B, C, D', '[,]', 1) + 1; Note: REGEXP_SUBSTR is A string truncation regular expression: a, B, C, and D are the string to be intercepted. [^,] + is the regular expression matching mode. Matching starts with any character other than commas, A segment of characters ending with any character other than a comma. Starting from a character, ROWNUM is the matched ROWNUM string. REGEXP_COUNT is the regular expression of the number query: A, B, C, D is the string to be truncated; [,] is the regular expression matching mode, matching with commas, 1 is from the first character; REGEXP_COUNT + 1 can calculate how many substrings 3. list all the months between two months SELECT TO_CHAR (ADD_MONTHS (DATE '2017-03-01 ', ROWNUM-1), 'yyyy-mm ') months from dual connect by rownum <= MONTHS_BETWEEN (DATE '2017-03-01 ', DATE '2017-03-01') + 1; 4. list all days between two dates SELECT TO_CHAR (DATE '2017-05-11 '+ ROWNUM-1, 'yyyy-MM-DD ') as days from dual connect by rownum <= DATE '2017-01-02 '-date' 2018-03-07' + 1

PS: Let's take a look at the date of each day for a certain period of time in Oracle.

SELECT TO_DATE('2016-01-01', 'yyyy-MM-dd') + ROWNUM - 1 as daylist,TO_DATE('2016-01-01', 'yyyy-MM-dd') + ROWNUM as daylistsFROM DUALCONNECT BY ROWNUM <=trunc(to_date('2016-07-31', 'yyyy-MM-dd') -to_date('2016-01-01', 'yyyy-MM-dd')) + 1

Summary

The above section describes the data of each day in the oracle statistical period. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.