控件中国网现已改版,您看到的是老版本网站的镜像,系统正在为您跳转到新网站首页,请稍候.......
中国最专业的商业控件资讯网产品咨询电话:023-67870900 023-67871946
产品咨询EMAIL:SALES@COMPONENTCN.COM

月份统计精简Sql

作者:佚名 出处:互联网 2011年03月18日 阅读:

月份统计精简Sql

SELECT
Q1.ProductName
,(Q2.M1 & Power(2,OrderDate)) *  SaleVolume AS M1
,(Q2.M2 & Power(2,OrderDate)) *  SaleVolume AS M2
,(Q2.M3 & Power(2,OrderDate)) *  SaleVolume AS M3
,(Q2.M4 & Power(2,OrderDate)) *  SaleVolume AS M4
,(Q2.M5 & Power(2,OrderDate)) *  SaleVolume AS M5
,(Q2.M6 & Power(2,OrderDate)) *  SaleVolume AS M6
,(Q2.M7 & Power(2,OrderDate)) *  SaleVolume AS M7
,(Q2.M8 & Power(2,OrderDate)) *  SaleVolume AS M8
,(Q2.M9 & Power(2,OrderDate)) *  SaleVolume AS M9
,(Q2.M10 & Power(2,OrderDate)) *  SaleVolume AS M10
,(Q2.M11 & Power(2,OrderDate)) *  SaleVolume AS M11
,(Q2.M12 & Power(2,OrderDate)) *  SaleVolume AS M12
FROM
(
SELECT
T3.[name] AS ProductName
,datepart(MM, T2.orderdate) AS OrderDate
,SUM(ISNULL(T1.totalretailvalue,0.00)) AS SaleVolume
FROM [Order] T1
INNER JOIN
OrderPart T2
ON T1.id = T2.[orderno]
INNER JOIN
m_product T3
ON T2.collectionid = T3.id
WHERE T1.isdeleted = 0 AND T3.id = $ProductId$ AND datepart(YEAR, T2.orderdate) = $Year$
GROUP BY T3.[name],datepart(MM, T2.orderdate)
) Q1

CROSS JOIN
(
SELECT 1 AS M1,2 AS M2,4 AS M3,8 AS M4, 16 AS M5,32 AS M6,64 AS M7,128 AS M8, 256 AS M9, 512 AS M10, 1024 AS M11, 2048 AS M12
) Q2

 

热推产品

  • ActiveReport... 强大的.NET报表设计、浏览、打印、转换控件,可以同时用于WindowsForms谀坔攀戀Forms平台下......
  • AnyChart AnyChart使你可以创建出绚丽的交互式的Flash和HTML5的图表和仪表控件。可以用于仪表盘的创......
首页 | 新闻中心 | 产品中心 | 技术文档 | 友情连接 | 关于磐岩 | 技术支持中心 | 联系我们 | 帮助中心 Copyright-2006 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 电话:023 - 67870900 传真:023 - 67870270 产品咨询:sales@componentcn.com 渝ICP备12000264号 法律顾问:元炳律师事务所 重庆市江北区塔坪36号维丰创意绿苑A座28-5 邮编:400020
在线客服
在线客服系统
在线客服
在线客服系统