69.Oracle数据库SQL开发之 高级查询——用位置标记和符号标记访问数据单元
欢迎转载,转载请标明出处:http://blog.csdn.net/notbaron/article/details/49847091
Sales_amount[1,2004],其中1代表月份,2004代表年份。这种方式成为位置标记,因为维度的含义是通过其位置决定的。
可以使用符号标记显示指定维度的含义。
store@PDB1> selectprd_type_id,year,month,sales_amount from all_sales where prd_type_id between 1and 2 and emp_id=21
model
partitionby (prd_type_id)
dimensionby (month,year)
measures(amount sales_amount) (
sales_amount [month=1,year=2004]=sales_amount[month=1,year=2003],
sales_amount[month=2,year=2004]=
sales_amount[month=2,year=2003]+sales_amount[month=3,year=2003],
sales_amount[month=3,year=2004]=ROUND(sales_amount[month=3,year=2003]*1.25,2)
)
order byprd_type_id,year,month;
PRD_TYPE_ID YEAR MONTH SALES_AMOUNT
----------- ---------- ----------------------
1 2003 1 10034.84
1 2003 2 15144.65
1 2003 3 20137.83
1 2003 4 25057.45
1 2003 5 17214.56
1 2003 6 15564.64
1 2003 7 12654.84
1 2003 8 17434.82
1 2003 9 19854.57
1 2003 10 21754.19
1 2003 11 13029.73
1 2003 12 10034.84
2 2003 1 1034.84
2 2003 2 1544.65
2 2003 3 2037.83
2 2003 4 2557.45
2 2003 5 1714.56
2 2003 6 1564.64
2 2003 7 1264.84
2 2003 8 1734.82
2 2003 9 1854.57
2 2003 10 2754.19
2 2003 11 1329.73
2 2003 12 1034.84
24 rows selected.
使用位置或符号标记之间有一个区别需要了解,即他们处理维度中空值的方式不同。