SQL statement to find the time difference. such as the following data

Source: Internet
Author: User

MSISDN                    createtime                             closetime
138 2011-5-17 15:30:00:000 2011-5-17 15:30:00:530
138 2011-5-17 15:40:00:000 2011-5-17 15:40:00:530
How much time does it take to query the number 138 using the SQL statement?



===============================================

Select SUM (DateDiff (Millisecond,createtime, Closetime)) as total Hao seconds from table name where msisdn=138

Select SUM (DateDiff (Minute,createtime, Closetime)) as total number of seconds from table name where msisdn=138

Select SUM (DateDiff (Minute,createtime, Closetime)) as total minutes from table name where msisdn=138

Select SUM (DateDiff (Hour,createtime, Closetime)) as total hours from table name where msisdn=138

Select SUM (DateDiff (Day,createtime, Closetime)) as Total days from table name where msisdn=138

Select SUM (DateDiff (Week,createtime, Closetime)) as Total days from table name where msisdn=138

Select SUM (DateDiff (Month,createtime, Closetime)) as Total days from table name where msisdn=138

Select SUM (DateDiff (Quarter,createtime, Closetime)) as total number of seasons from table name where msisdn=138

Select SUM (DateDiff (Year,createtime, Closetime)) as total number of years from table name where msisdn=138

SQL statement to find the time difference. such as the following data

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.