标签:style code http color com 使用
5 SELECT <columnlist>1 FROM <source objectlist>1.1 FROM <left source object><join type>
2 WHERE <wherepredicates>JOIN <right source object>ON <on predicates(谓词,判断)>
3 GROUP BY <group byexpression(s)>
4 HAVING <having predicates>
6 ORDER BY <order by list>-FROM子句:
-GROUP BY子句1、交叉联结,也称笛卡尔积;2、内联结;3、外联结。
-HAVING子句将执行FROM和WHERE后得到的经过筛选后的结果集进行聚合。结果集按照GROUPBY子句列出的表达式进行分组,来为每一个分组得出一行汇总结果。可按照FROM子句中所列出对象的任意字段进行分组,即使并不在结果中显示该列。但SELECT子句列表中的任何非聚合字段都必须包含在GROUPBY表达式中。GROUPBY还可包含两个附加运算:ROLLUP,CUBE。ROLLUP产生部分求和值,CUBE求得交互分类值。
INSERT ALLWHEN sum_orders < 10000 THENINTO small_customersWHEN sum_orders >= 10000 AND sum_orders <100000THENINTO medium_customersELSEINTO large_customersSELECT customer_id,sum(order_total) sum_ordersFROM ordersGROUP BY customer_id;
UPDATE (SELECT e1.salary,e2.salary new_salFROM employees e1,employees2 e2WHERE e1.employee_id=e2.employee_idAND e1.department_id=90)SET salary = new_sal;
UPDATE employeesSET (salary,commission_pct) = (SELECT employees2.salary, .10comm_pct
WHERE department_id=90;FROM employees2WHEREemployee2.employee_id=employees.employee_idAND employees.salary != employees2.salary)
DELETE FROM employees2WHERE department_id = 90;
DELETE FROM (SELECT * FROM employees2 WHERE department_id =90);
DELETE FROM employees2WHERE department_id IN (SELECT department_id
FROM departmentsWHERE department_name =‘Excutive‘);
[LOG ERRORS <long_errors_clause> <reject limit <integer | unlimited>];
MERGE <hint>
INTO <tablename>
USING <table_view or query>
ON (<condition>)
WHEN MATCHED THEN <update_clause>
DELETE <where_clause>
WHEN NOT MATCHED THEN <insert_clause>
MERGE
INTO dept60_bonus bUSING (
SELECT employee_id,salary,department_id
FROM employees
WHERE department_id = 60) e
ON (b.employee_id = e.employee_id)
WHEN MATCHED THEN
UPDATE SET b.bonus_amt = e.salary * 0.2 WHERE b.bonus_amt = 0
DELETE WHERE (e.salary > 7500)
WHEN NOT MATCHED THEN
INSERT (b.employee_id,b.bonus_amt)
VALUES(e.employee_id,e.salary*0.1)
WHERE (e.salary < 7500)
标签:style code http color com 使用
原文地址:http://www.cnblogs.com/shadowwalker/p/3800270.html