清单 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"
|
|