sql 显示如何拉出列表,在特定日期之间拉出某些上诉和贡献,以及(customer 4)按customer_no和HAVING S分组

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 显示如何拉出列表,在特定日期之间拉出某些上诉和贡献,以及(customer 4)按customer_no和HAVING S分组相关的知识,希望对你有一定的参考价值。

SELECT DISTINCT a.customer_no FROM V_CUSTOMER_WITH_PRIMARY_GROUP a WITH (NOLOCK)
 JOIN (SELECT a1.customer_no FROM lvs_soft_credit a1 WITH (NOLOCK) WHERE a1.appeal_no IN (2830,3649,3435) 
 AND a1.cont_dt BETWEEN '2016/01/01' And '2017/06/30 23:59:59' 
 GROUP BY a1.customer_no HAVING SUM(a1.cont_amt) >= .01) AS e 
 ON e.customer_no = a.customer_no
 JOIN (SELECT a1.customer_no From VXS_CONST_CUST a1 WITH (NOLOCK) WHERE a1.constituency IN (4,25)) AS f 
 ON f.customer_no = a.customer_no
 Where IsNull(a.inactive, 1) = 1 
 
 -- START DETAIL!!!
 
 -- Select distinct customer_no from V_CUSTOMER_WITH_PRIMARY_GROUP
 SELECT DISTINCT a.customer_no FROM V_CUSTOMER_WITH_PRIMARY_GROUP a WITH (NOLOCK)
 
 -- JOIN patrons with appeals 2830, 3649, 3435 in lvs_soft_credit
 JOIN (SELECT a1.customer_no FROM lvs_soft_credit a1 WITH (NOLOCK) WHERE a1.appeal_no IN (2830,3649,3435) 
 
 -- AND having a contribution between these dates (part of the JOIN started on line 15)
 AND a1.cont_dt between  '2016/01/01' And '2017/06/30 23:59:59' 
 
 -- GROUP the results of the JOIN by customer_no and select patrons HAVING the SUM(cont_amt) greater than or equal to .01), ends the JOIN started on line 15, names the result of this JOIN 'e'
 GROUP BY a1.customer_no HAVING SUM(a1.cont_amt) >= .1) AS e 
 
 -- ON, says match the patrons up based on customer_no in lvs_soft_credit being the same as customer_no in V_CUSTOMER_WITH_PRIMARY_GROUP
 ON e.customer_no = a.customer_no
 
-- Then further JOIN patrons who have constituencies 4 and 25 in VXS_CONST_CUST, name the results 'f'
 JOIN (SELECT a1.customer_no From VXS_CONST_CUST a1 WITH (NOLOCK) WHERE a1.constituency IN (4,25)) AS f 
 
 -- ON, says match the patrons up based on customer_no in VSX_CONST_CUST being the same as customer_no in V_CUSTOMER_WITH_PRIMARY_GROUP
 ON f.customer_no = a.customer_no
 
-- filters out inactives
 WHERE IsNull(a.inactive, 1) = 1 

以上是关于sql 显示如何拉出列表,在特定日期之间拉出某些上诉和贡献,以及(customer 4)按customer_no和HAVING S分组的主要内容,如果未能解决你的问题,请参考以下文章

sql 下面的查询将拉出所选的lskin输入日期以来的所有呼叫,按日,总呼叫和唯一呼叫进行细分

存储在 SQL Server DB 中的 DateTime 不考虑夏令时。当我把它拉出来时,我该如何解决这个问题?

text [UTC日期]以UTC格式在数据库中存储日期并将其拉出并在当地时间显示。 C ##Dates #JavaScript

红宝石 - 如何拉出两个“点”之间的? [复制]

如何根据其中引用的当前帖子拉出帖子对象?

Excel 控件中的checkbox 如何被选中? 为啥不是像"窗体"中的复选框一样,拉出来,直接用鼠标单击就能选中了