In MSSQL, with as and timeline are used to calculate the details and total number of news releases.

Source: Internet
Author: User

In MSSQL, with as and timeline are used to calculate the details and total number of news releases.

With cr as (SELECT AddTime, [edit name 1], [edit name 2], [edit name 3] FROM (SELECT NewsID, AddTime, AuditingUser FROM News) AS a distinct (COUNT (. newsID) FOR. auditingUser in ([edit name 1], [edit name 2], [edit name 3]) as PVTWHERE AddTime between '2017-11-24 00:00:00 'and '2017-11-30 23:59:59' group by AddTime, [edit name 1], [edit name 2], [edit name 3]) select convert (NVARCHAR (50), AddTime, 120) as 'time', [edit name 1], [edit name 2], [edit name 3] from crunion (SELECT 'Total' AS AddTime, SUM (CR. [edit name 1]) AS 'edit name 1', SUM (CR. [edit name 2]) AS [edit name 2], SUM (CR. [edit name 3]) AS [edit name 3] from cr)

Set the compatibility of the target database to 90 (sql2005) or above before execution. Otherwise, an error is reported.

Result:

Time edit name 1 edit name 2 edit name 32014-11-24 08:36:031002014-11-24 09:42:150012014-11-24 09:42:310102014-11-24 09:43:251002014-11-24 hours-11-24 130014 -11-24 10: 31: 170012014-11-24 10: 39: 360012014-11-24 120102014-11-24 11: 28: 570002014-11-24 14: 28: 570102014-11-24-051002014-11-24 :340102014-11-24 :35:540102014-11-24 :37:251002014-11-24-11-24 15: 49: 390102014-11-24 am--11-24 am-101002014-11-24 am-11-24 am-501002014-11-24 Am-11 Am-24 Am-11-24 Am-Am 17: 01: 270002014-11-24 17: 17: 160012014-11-24 350002014-11-25 08:44:350102014-11-25 09: 18: 060102014-11-25 09: 23: 491002014-11-25 am 37:550102014-11-25 am 50:530012014-11-25 am 0:300012014-11-25 am 28:110102014-11-25 am 102014-11-25 14: 35: 091002014-11-25 Am-11-25 am-070012014-11-25 Am-11-25 15: 28:-11-25 am: 240012014-11-25 15: 35: 080012014-11-25-11-25-521002014-11-25-11-25-130012014-11-25 :44:331002014-11-25 :53:331002014-11-25 :06:541002014-11-25 PM 1002014-11-25 pm-11-26 pm-11-26 09: 01: 380102014-11-26 530102014-11-26 09: 22: 491002014-11-26 09: 31: 260102014-11-26 10: 01: 380012014-11-26-11-26-11-11-26-26-150102014-11-26 :300012014-11-26-550102014-11-26-11-26 210102014-11-26 14: 50: 070102014-11-26: 400102014-11-26: 501002014-11-26: 241002014-11-26: 411002014-11-26: 220102014-11-26: 420012014-11-26 16: 27: 360102014-11-26 16: 38: 381002014-11-26 16: 39: 580012014-11-26 16: 42: 170012014-11-26 :45:110012014-11-26 140012014-11-27 08: 41: 460102014-11-27 08: 50: 381002014-11-27-120102014-11-27 09: 50: 591002014-11-27-320102014-11-27 10: 36: 091002014-11-27 10: 54: 570012014-11-27 14: 16: 581002014-11-27 14: 45: 370102014-11-27 :50:220012014-11-27 130012014-11-27 14: 55: 290102014-11-27-230012014-11-27 15: 07: 490012014-11-27 15: 19: 070012014-11-27: 140102014-11-27: 250102014-11-27: 041002014-11-27 15: 58: 480012014-11-27 16: 08: 590012014-11-27 530102014-11-27-100012014-11-27 16: 19: 591002014-11-27 16: 41: 571002014-11-28 08:46:401002014-11-28 09: 03: 070102014-11-28 09:27:110102014-11-28 09:44:440012014-11-28 09: 48: 480012014-11-28 am-520102014-11-28 10: 34: 090012014-11-28 AM: 200102014-11-28 10: 51: 161002014-11-28 am-251002014-11-28 11: 44: 271002014-11-28 14: 36: 291002014-11-28 am-200012014-11-28 AM: 430012014-11-28 AM: 40: 291002014-11-28 am-420012014-11-28 AM: 401002014-11-28 16: 07: 171002014-11-28 Am-11-28 am 12014-11-28 Am-11-28 17: 02: 380012014-11-28 21: 24: 180002014-11-29 08: 31: 360002014-11-29-320012014-11-29-140012014-11-29 :430012014-11-29 13: 13: 160012014-11-29 :20:210012014-11-29 :30:120012014-11-29 :42:310012014-11-29 20: 30: 360002014-11-29 030002014-11-29 300012014-11-30 12: 12: 080012014-11-30 12: 30: 360012014-11-30 12: 33: 360012014-11-30 540012014-11-30 12: 43: 380012014-11-30 12: 52: 180012014-11-30 12: 56: 470012014-11-30 :55:540012014-11-30 :55:550012014-11-30 :30:410012014-11-30 :48:150012014-11-30 ::550012014-11-30 18: 56: 590012014-11-30-363966-11-30 total



Zookeeper

Related Article

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.