mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Oracle支持GroupingSets Clause
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@155 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -27,7 +27,10 @@ public class OracleSQLParserResourceTest extends TestCase {
|
||||
// exec_test("bvt/parser/oracle-8.txt");
|
||||
// exec_test("bvt/parser/oracle-9.txt");
|
||||
// exec_test("bvt/parser/oracle-10.txt");
|
||||
exec_test("bvt/parser/oracle-11.txt");
|
||||
// exec_test("bvt/parser/oracle-11.txt");
|
||||
// exec_test("bvt/parser/oracle-12.txt");
|
||||
// exec_test("bvt/parser/oracle-13.txt");
|
||||
exec_test("bvt/parser/oracle-14.txt");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
SELECT department_id, MIN(salary), MAX (salary)
|
||||
FROM employees
|
||||
GROUP BY department_id
|
||||
ORDER BY department_id;
|
||||
---------------------------
|
||||
SELECT department_id, MIN(salary), MAX(salary)
|
||||
FROM employees
|
||||
GROUP BY department_id
|
||||
ORDER BY department_id;
|
||||
@@ -0,0 +1,15 @@
|
||||
SELECT DECODE(GROUPING(department_name), 1, 'All Departments',
|
||||
department_name) AS department_name,
|
||||
DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job_id,
|
||||
COUNT(*) "Total Empl", AVG(salary) * 12 "Average Sal"
|
||||
FROM employees e, departments d
|
||||
WHERE d.department_id = e.department_id
|
||||
GROUP BY CUBE (department_name, job_id)
|
||||
ORDER BY department_name, job_id;
|
||||
---------------------------
|
||||
SELECT DECODE(GROUPING(department_name), 1, 'All Departments', department_name) AS department_name, DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job_id, COUNT(*) AS COUNT, AVG(salary) * 12 AS salary
|
||||
FROM employees e , departments d
|
||||
WHERE d.department_id = e.department_id
|
||||
GROUP BY CUBE(department_name, job_id)
|
||||
ORDER BY department_name, job_id;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
SELECT channel_desc, calendar_month_desc, co.country_id,
|
||||
TO_CHAR(sum(amount_sold) , '9,999,999,999') SALES$
|
||||
FROM sales, customers, times, channels, countries co
|
||||
WHERE sales.time_id=times.time_id
|
||||
AND sales.cust_id=customers.cust_id
|
||||
AND sales.channel_id= channels.channel_id
|
||||
AND customers.country_id = co.country_id
|
||||
AND channels.channel_desc IN ('Direct Sales', 'Internet')
|
||||
AND times.calendar_month_desc IN ('2000-09', '2000-10')
|
||||
AND co.country_iso_code IN ('UK', 'US')
|
||||
GROUP BY GROUPING SETS(
|
||||
(channel_desc, calendar_month_desc, co.country_id),
|
||||
(channel_desc, co.country_id),
|
||||
(calendar_month_desc, co.country_id) );
|
||||
---------------------------
|
||||
SELECT channel_desc, calendar_month_desc, co.country_id, TO_CHAR(sum(amount_sold), '9,999,999,999') AS SALES$
|
||||
FROM sales , customers , times , channels , countries co
|
||||
WHERE sales.time_id = times.time_id AND (sales.cust_id = customers.cust_id AND (sales.channel_id = channels.channel_id AND (customers.country_id = co.country_id AND (channels.channel_desc IN ('Direct Sales', 'Internet') AND (times.calendar_month_desc IN ('2000-09', '2000-10') AND co.country_iso_code IN ('UK', 'US'))))))
|
||||
GROUP BY GROUPING SETS ((channel_desc, calendar_month_desc, co.country_id), (channel_desc, co.country_id), (calendar_month_desc, co.country_id));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user