SQL Server Drip Accumulation

Source: Internet
Author: User
1. The column in the select list is not valid because the column is not contained in an aggregate function or a GROUP by clause

A: When you specify group BY, all columns in any non-aggregate expression in the selection list should be included in the group by list, or the group by expression must exactly match the select list expression.

2. Use of the case and then else end syntax

Select
I.index_name,i.index_def,
SUM (case when w.years= and then W.actual_value else 0 end) as A1,
SUM (case when w.years= and then w.ranking else 0 end) as R1,

SUM (case if w.years= (2014-1) then W.actual_value else 0 end) as A2,
SUM (case if w.years= (2014-1) then w.ranking else 0 end) as R2,


From Bm_work W,bm_index I
where
W.indexdef_id=i.uuid and
W.ent_id= ' 2c90e4da49514c750149515eb56f0003 ' and w.summary_state=2
Group BY I.index_name,i.index_def;

This statement achieves such an effect



SQL Server Drip Accumulation

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.