Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103782616
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类:

2008-04-12 09:50:43

来源:IBM developerWorks 中国网站    作者:Jason Dere

清单 1. 基于多维数据集模型的 SQL 查询

SELECT[1]	T1."MONTH_NUMBER" AS "MONTH_NUMBER (TIME)",	T1."YEAR" AS "YEAR (TIME)",	T1."MONTH_NAME" AS "MONTH_NAME (TIME)",	'Qtr ' CONCAT  (cast(T1."QUARTER_NUMBER" as char(1)))
AS "QUARTER_NAME", T3."CITY_NAME" AS "CITY_NAME (LOCATION)", T3."STATE_NAME" AS "STATE_NAME(LOCATION)", T4."PRODUCTID" AS "PRODUCTID (PRODUCT)", T5."LINE_NAME" AS "LINE_NAME (LINE)",[2] SUM(T7."SALES") AS "SALES (SALESFACT)", SUM((T7."COGS") + (T7."ADVERTISING"))
AS "Total Expense" FROM [3] "CVSAMPLE"."TIME" AS T1, "CVSAMPLE"."STORE" AS T2, "CVSAMPLE"."LOCATION" AS T3, "CVSAMPLE"."PRODUCT" AS T4, "CVSAMPLE"."LINE" AS T5, "CVSAMPLE"."FAMILY" AS T6, "CVSAMPLE"."SALESFACT" AS T7WHERE[4] (T2."POSTALCODEID" = T3."POSTALCODEID" AND T4."LINEID" = T5."LINEID" AND T5."FAMILYID" = T6."FAMILYID" AND T7."TIMEID" = T1."TIMEID" AND T7."STOREID" = T2."STOREID" AND T7."PRODUCTID" = T4."PRODUCTID")[5] AND (T1."YEAR" = 2003 AND T1."MONTH_NAME" = 'December' AND T3."STATE_NAME" = 'California' AND T3."CITY_NAME" = 'Milpitas' AND T6."FAMILY_NAME" = 'Colas')GROUP BY [1] T1."MONTH_NUMBER", T1."YEAR", T1."MONTH_NAME", 'Qtr ' CONCAT (cast(T1."QUARTER_NUMBER" as char(1))), T3."CITY_NAME", T3."STATE_NAME", T4."PRODUCTID", T5."LINE_NAME"

阅读(406) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~