How to calculate the period-over-period ratio of an SQL statement! The number of resumes in this month minus the number in the previous month (as shown in the figure)

Source: Internet
Author: User
How to calculate the period-over-period ratio of an SQL statement! This month's resume count minus () last month's resume [this month's resume count]-[last month's resume count] = [month-on-month ratio] () how to write SQL statements? SELECTDATE_FORMAT (m_adddate, '% M') & nbsp; as & nbsp; month, count (m_id) & nbsp; how to calculate the period-over-period ratio of an SQL statement! The number of resumes in this month minus the number of resumes in the previous month ()

[Number of resumes this month]-[number of resumes in the previous month] = [number of resumes in the previous month ]()

How to write SQL statements?
SELECTDATE_FORMAT (m_adddate, '% M') as month, count (m_id) as zong, DATE_FORMAT (m_adddate,' % Y') as year from job_myreceive where DATE_FORMAT (m_adddate, '% Y') = 2011 group by DATE_FORMAT (m_adddate,' % M'); shared:
------ Solution --------------------
Well, you can write it clearly.
SELECT DATE_FORMAT (a. m_adddate, '% Y % M') as Ym, count (*) as 'month ',
(Select count (*) from job_myreceive where
DATE_FORMAT (a. m_adddate, '% Y % M') = DATE_FORMAT (DATE_add (m_adddate, INTERVAL 1 MONTH),' % Y % M ')
) As last month
FROM job_myreceive a group by 1

Ym last month
201012 6 0
201101 2 6
201105 1 0
201107 2 0
201112 1 0
201305 1 0

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.