搜尋此網誌
2010年10月4日 星期一
2010年10月3日 星期日
Grouping
---http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions064.htm
Purpose
GROUPING distinguishes superaggregate rows from regular grouped rows. GROUP BY extensions such as ROLLUP and CUBE produce superaggregate rows where the set of all values is represented by null. Using the GROUPING function, you can distinguish a null representing the set of all values in a superaggregate row from a null in a regular row.
The expr in the GROUPING function must match one of the expressions in the GROUP BY clause. The function returns a value of 1 if the value of expr in the row is a null representing the set of all values. Otherwise, it returns zero. The datatype of the value returned by the GROUPING function is Oracle NUMBER. Refer to the SELECT group_by_clause for a discussion of these terms.
Examples
In the following example, which uses the sample tables hr.departments and hr.employees, if the GROUPING function returns 1 (indicating a superaggregate row rather than a regular row from the table), then the string "All Jobs" appears in the "JOB" column instead of the null that would otherwise appear:
SELECT
DECODE(GROUPING(department_name), 1, 'All Departments', department_name) AS department,
DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job,
COUNT(*) "Total Empl",
AVG(salary) * 12 "Average Sal"
FROM employees e, departments d
WHERE d.department_id = e.department_id
GROUP BY ROLLUP (department_name, job_id)
ORDER BY department, job, "Total Empl", "Average Sal";
DEPARTMENT JOB Total Empl Average Sal
------------------------------ ---------- ---------- -----------
Accounting AC_ACCOUNT 1 99600
Accounting AC_MGR 1 144000
Accounting All Jobs 2 121800
Administration AD_ASST 1 52800
Administration All Jobs 1 52800
All Departments All Jobs 106 77479.2453
Executive AD_PRES 1 288000
Executive AD_VP 2 204000
Executive All Jobs 3 232000
Finance All Jobs 6 103200
Finance FI_ACCOUNT 5 95040
. . .
2010年9月26日 星期日
FLASHBACK QUERY
FLSHBACK-DATA-REFERENCES 參考文件
Select * from xxxx-table VERSIONS BETWEEN
Select * from xxxx-table VERSIONS BETWEEN
TIMESTAMP MINVALUE AND MAXVALUE ;
2010年9月23日 星期四
2010年9月19日 星期日
PYTHON-LOOP
#!/usr/bin/python
flag = 0
while flag ==0: 當值等於0時才會執行
num = raw_input("Enter number:")
print "you type",num
flag = raw_input("Enter value:") #使用者輸入資料
if flag == quit:
break :跳出迴圈
print "good bye"
在PYTHON 的設定 縮排可用TAB或空白.. 但不能混用
如用空白 ,請空4格
flag = 0
while flag ==0: 當值等於0時才會執行
num = raw_input("Enter number:")
print "you type",num
flag = raw_input("Enter value:") #使用者輸入資料
if flag == quit:
break :跳出迴圈
print "good bye"
在PYTHON 的設定 縮排可用TAB或空白.. 但不能混用
如用空白 ,請空4格
訂閱:
文章 (Atom)



