Number of phone calls and duration

Source: Internet
Author: User
-- Number of phone calls and duration

Declare @ t table (ID int, number int, call duration varchar (8 ))
Insert into @ t
Select 1,21981052, '00: 01: 19 'Union all
Select 2,21981052, '00: 00: 26' Union all
Select 3,21980021, '00: 00: 56' Union all
Select 4,21980389, '00: 02: 05 'Union all
Select 5, 21980389, '00: 00: 41 'Union all
Select 6, 21981056, '00: 00: 31 'Union all
Select 7,21981056, '00: 00: 13'

Select number, count (*) as call count,
Convert (varchar (8), dateadd (SS, sum (datediff (SS, 0, call duration), 0), 108) Call duration
From @ t
Group by number
Order by number
/*
Number of calls call duration
------------------------------
21980021 00:00:56
21980389 00:02:46
21981052 00:01:45
21981056 00:00:44

(The number of affected rows is 4)
*/

-- Ss seconds

/*
Select convert (varchar (12), getdate (), 108)
11:06:08
*/

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.