[SQL ] 将SQL查询结果 再做群组汇总

楼主: nd5287 (Mike)   2017-09-07 00:58:39
数据库名称:
数据库版本:sql 2014
内容/问题描述:
我下了 以下的语法查询出的结果如下
select DISTINCT B.CU_order_amount "金额",D.CU_name as "地区",
B.BillDate as "日期" from CU_order B
join CU_cust_info C on B.CU_cust_id=C.CU_cust_id
join CU_city D on C.CU_city_id = D.CU_Id
where B.CU_cust_id in
(select CU_cust_id from CU_cust_info C where CU_city_id in (select CU_city_id
from CU_city ))
and B.BillDate Between '20160101' and '20171231'
order by B.CU_order_amount desc
金额 地区 日期
作者: criky (2501-2)   2017-09-07 07:34:00
把查询结果当子查询表格
楼主: nd5287 (Mike)   2017-09-07 07:52:00
所以是再用一个Select最后 from 把第一次的查询结果()起吗?

Links booklink

Contact Us: admin [ a t ] ucptt.com