Cumulative sum of SQL Server numbers

Source: Internet
Author: User

Tag:declare   sum   post    Plan    class    float   --   blog   rom   

DECLARE @ Battery table table (date int, day capacity float, planned power yield float, daily average yield float) insert INTO @ battery Gauge Select 1,3.8788,null,3.8024 INSERT INTO @ Battery gauge Select 2,3.8846, null,3.8024 INSERT INTO @ battery gauge Select 3,3.7841, null,3.8024 INSERT INTO @ battery gauge Select 4,3.7946,null,3.8 024 INSERT INTO @ battery Gauge Select 5,3.7672,null,3.8024 INSERT INTO @ battery Gauge Select 6,3.7178,null,3.8024 INSERT INTO @ battery Gauge Select 7      , 3.7871,null,3.8024 Select M. Date, SUM (DL. Daily power generation) as charge cumulative from @ Battery table DL INNER JOIN (SELECT * from @ battery gauge) M On (DL. Date <= m. date)--where M. Date <= 7 GROUP by M. Date, M. Day power Generation ORDER by M. Date

Cumulative sum of SQL Server numbers

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.