B2C经典查询,统计 绝对用的上,根据日期分组统计当天各种支付方式的销售数量和销售额
来源:互联网 发布:yy音效软件 编辑:程序博客网 时间:2024/06/06 13:09
declare @sql varchar(8000)
set @sql = 'select CONVERT(varchar(10), OrderDate, 120) as 日期'
select @sql = @sql + ' , sum(case PayWay when ''' + cast(Pwy as varchar)+ ''' then OrderAmount else 0 end)[' + cast(Pwy2 as varchar) + ']
,sum(case PayWay when ''' + cast(Pwy as varchar)+ ''' then 1 else 0 end)[' + cast(Pwy2 as varchar) + '销量]'
from (select distinct id as Pwy,PayWay as Pwy2 from dbo.A_OrderPayWay) as a
set @sql = @sql + ',sum( case OrderAmount when NULL then 0 else OrderAmount end ) as 合计,count(*) as 总订单 from A_OrderInfo group by
CONVERT(varchar(10), OrderDate, 120) Order by CONVERT(varchar(10), OrderDate, 120) desc'
exec(@sql)
备注
[' + cast(Pwy2 as varchar) + '销量] //列名转换
CONVERT(varchar(10), OrderDate, 120) //获取订单日期的 年月日部分
sum(case PayWay when ''' + cast(Pwy as varchar)+ ''' then OrderAmount else 0 end) //统计每种支付方式的当天金额
sum(case PayWay when ''' + cast(Pwy as varchar)+ ''' then 1 else 0 end) //统计每种支付方式的当天销售数量
select distinct id as Pwy from dbo.A_OrderPayWay //获取所以支付类型
- B2C经典查询,统计 绝对用的上,根据日期分组统计当天各种支付方式的销售数量和销售额
- 根据日期统计某一个字段的在当天的总和
- oracle分组统计查询之后,获取数量最大的记录
- mysql的分组查询、分组统计
- 增值税:特殊销售方式下的销售额
- sicily 1003. 统计各种字符的数量
- 表查询结果的数量统计,和,平均值,最大值,最小值
- sql统计当天的数据
- 统计网站当天的访问量
- 关于 分组查询的分页,统计
- 统计文件的数量
- 根据hash统计数组中各个元素的数量
- 统计两个日期之间的工作日的数量
- solr 的分组统计
- awk 统计各种文件的数量 以及数组
- oracle 统计redo统计当天日志生成和最近日期日志生成统计
- 【练手】cube和grouping的分组统计
- Extjs4--grid表格的分组和统计
- 地宫取宝----第五届蓝桥杯
- linux读写锁
- ERROR/AndroidRuntime(716): java.lang.SecurityException: Binder invocation to an incorrect interface
- hdu1846 Brave Game
- poj - 1579 - Function Run Fun(记忆化搜索)
- B2C经典查询,统计 绝对用的上,根据日期分组统计当天各种支付方式的销售数量和销售额
- Activity的四种启动模式的自白
- 基于windows的源地址路由
- 王立平--SQLite,SQLiteOpenHelper的简单应用
- 单行、多行输入框,其属性及功能场景
- [置顶] 构建高并发高可用的电商平台架构实践
- linux自旋锁
- Mongodb用户和认证 权限总结
- 解决Fragment中放置ViewPager,不执行adapter的方法