不好意思,刚才一着急漏掉了一点东西!!对不起 select customer_id,customer_name,customer_type,sum(customer_id) from customer_co de GROUP BY location_id;
select customer_id,customer_name,customer_type,sum(customer_id) from customer_code GROUP BY customer_id,customer_name,customer_type;
select customer_id,customer_name,customer_type,sum(customer_id) from customer_code GROUP BY customer_id,customer_name,customer_type;
select location_id,customer_id,customer_name, customer_type,sum(customer_id) from customer_code GROUP BY location_id,customer_id,customer_name,customer_type;
select customer_id,customer_name,customer_type,tot_id from customer_code where rowid in(select min(rowid),sum(customer_id) as tot_id from customer_code GROUP BY customer_id);
select customer_id,customer_name,customer_type from customer_code group by customer_id,customer_name,customer_type
In a simple GROUP BY clause, you can use either the upper or lower form of expression list: SELECT department_id, MIN(salary), MAX(salary) FROM employees GROUP BY department_id, salary; SELECT department_id, MIN(salary), MAX(salary) FROM employees GROUP BY (department_id, salary); In ROLLUP, CUBE, and GROUPING SETS clauses of GROUP BY clauses, you can combine individual expressions with sets of expressions in the same expression list. The following example shows several valid grouping sets expression lists in one SQL statement: SELECT prod_category, prod_subcategory, country_id, cust_city, count(*) FROM products, sales, customers WHERE sales.prod_id = products.prod_id AND sales.cust_id=customers.cust_id AND sales.time_id = ¡¯01-oct-00¡¯ AND customers.cust_year_of_birth BETWEEN 1960 and 1970 GROUP BY GROUPING SETS ( (prod_category, prod_subcategory, country_id, cust_city), (prod_category, prod_subcategory, country_id), (prod_category, prod_subcategory), country_id );
select customer_id,customer_name,customer_type,sum(customer_id) from customer_co
de GROUP BY location_id;
from customer_code
GROUP BY customer_id,customer_name,customer_type;
from customer_code
GROUP BY customer_id,customer_name,customer_type;
customer_type,sum(customer_id)
from customer_code
GROUP BY location_id,customer_id,customer_name,customer_type;
还有贴主能不能把你要写的sql语句的意思说一下,才方便帮你啊。
from customer_code
where rowid in(select min(rowid),sum(customer_id) as tot_id from customer_code GROUP BY customer_id);
from customer_code
group by customer_id,customer_name,customer_type
expression list:
SELECT department_id, MIN(salary), MAX(salary)
FROM employees
GROUP BY department_id, salary;
SELECT department_id, MIN(salary), MAX(salary)
FROM employees
GROUP BY (department_id, salary);
In ROLLUP, CUBE, and GROUPING SETS clauses of GROUP BY clauses, you can
combine individual expressions with sets of expressions in the same expression list.
The following example shows several valid grouping sets expression lists in one
SQL statement:
SELECT
prod_category, prod_subcategory, country_id, cust_city, count(*)
FROM products, sales, customers
WHERE sales.prod_id = products.prod_id
AND sales.cust_id=customers.cust_id
AND sales.time_id = ¡¯01-oct-00¡¯
AND customers.cust_year_of_birth BETWEEN 1960 and 1970
GROUP BY GROUPING SETS
(
(prod_category, prod_subcategory, country_id, cust_city),
(prod_category, prod_subcategory, country_id),
(prod_category, prod_subcategory),
country_id
);