Ask a database about the problem, there is a table, there are daily data deposited, how to remove the number of data per month

Source: Internet
Author: User
Ask for a database problem, there is a table, there are daily data deposited, how to take out the number of data per month.
This is the Ec_ip_article table, Iptime is the time stamp of the day. There is no easy way to do, do not want to every month of SQL out, and then count the number, that SQL too much.

------to solve the idea----------------------
Select From_unixtime (iptime, '%y-%m ') as M, Count (*) as CNT from Ec_ip_article GROUP by 1

------to solve the idea----------------------

Select From_unixtime (iptime, '%y%m%d '), COUNT (0) from Ec_ip_article Group by From_unixtime (Iptime, '%y%m%d ')

------to solve the idea----------------------
References:

Select From_unixtime (iptime, '%y%m%d '), COUNT (0) from Ec_ip_article Group by From_unixtime (Iptime, '%y%m%d ')


Select From_unixtime (iptime, '%y%m '), COUNT (0) from Ec_ip_article Group by From_unixtime (Iptime, '%y%m ')
------to solve the idea----------------------

SELECT Ip_id,count (ip_id) count,from_unixtime (iptime, '%y%m%d ') date from Test GROUP by From_unixtime (iptime, '%c ') ORDER by Iptime

  • 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.