1
table:citys
city ran
广州 A
广州 B
广州 C
广州 D
city ran
广州 A,B,C,D
请问oracle 的sql语句要怎么写?
select city,wmsys.wm_concat(ran)
from citys
group by city
2 备忘
insert into emp (id,name,sex,tim) --dual
values(id_seq.nextval,'junly',default,to_date('2010-5-11 11:25:00','yyyy-mm-dd hh24:mi:ss'))
3 直接装载
--直接装载方式
insert /**//*+append*/ into emp (field1,field2,field3)
select f1,f2,f3 from tep
where f4=20;
4 更新
--更新
update emp set (field1,field2,field3)=(
select f1,f2,f3 from tep where f4=20)
where field4=100;
5 取消重复
select count(distinct user_name) as num
from user_info
6 group by + rollup 横向小计
-- group by + rollup 横向小计
select num1,sum(num2),sum(num3) from tmp_tb
group by rollup (num1)
7 group by + cube 纵向小计
-- group by + cube 纵向小计
select num1,sum(num2),sum(num3) from tmp_tb
group by cube(num1)
8 自连接
-- 自连接
/**//* user_info
id name pid
-------------------
7888 king
7889 blank 7888
7900 jones 7888
*/
select manager.name from user_info manager,user_info worker
where manager.id=worker.pid
and worker.name='jones';
----------
king
9 ALL和ANY(不能单独使用,与单行比较符[=,>,<,>=,<=,<>]结合使用)
--ALL和ANY(不能单独使用,与单行比较符[=,>,<,>=,<=,<>]结合使用)
/**//*
ALL 必须要符合子查询结果的所有值
ANY 只要符合子查询结果的任一个值即可
*/
select user_name,money from user_info where money >all(
select money form user_game where id=10);
select user_name,money from user_info where money >any(
select money form user_game where id>10);
10 合并查询
--(1)union 取两个结果集的并集,自动去掉重复行并以第一列的结果排序
--(2)union all 取两个结果集的并集,不去重复行也不进行排序
--(3)intersect 取两个结果集的交集
--(4)minus 取两个结果集的差集
select uname,sal from emp where sal>200
union
select uname,sal from emp where job='aaa'
11 case条件分支
select name,case when money>3000 then 3
when money>2000 then 2 when money>1000 then 1 end
from user_info where user_id=10000;
12 with子名重用子查询
--with子名重用子查询
with summary as (
select name,sum(money) as total from user_info
group by name
)
select name,total from summary
where total>3000;
分享到:
相关推荐
ogg sqlserver-oracle mysql-oracle mysql-mysql的同步配置参考,少走弯路。
全国省市区所对应的sql文件--oracle版 需要你自己建立好对应的表和字段 直接执行sql文件即可 望见谅
SqlServer-Oracle技术文档
activity-oracle建表SQLactivity-oracle建表SQLactivity-oracle建表SQL
flinkcdc oracle 2.3.0
flink-sql-connector-oracle-cdc 2.5-SNAPSHOT
xxl-job-admin-oracle 2.3.0 修改为oracle版 sql xxl-job-admin-oracle\src\main\resources\sql\tables_xxl_job-oracle.sql
liferay-portal-sql-oracle-10-5.2.3.dmp
Oracle技术文档,Pl/SQl 的使用说明书
SQL-4-Oracle.pdf 官方的oracle sql练习手册,对学习sql很有帮助!
e12069-Oracle Database Gateway for SQL Server-82
NFine精简KO版,NFine精简KO版(支持MySql-Oracle-SqlServer-SQLite)!
Oracle可视化工具sqldeveloper-23.1.0.097.1607-x64
sqlserver与oracle数据库的数据类型对照
V2.0【2015-05】 1、新增 WORD 模板 功能;...1、支持的数据库类型:SQL Server 2005+,My SQL,Oracle; 2、支持的文档类型:HTML,CHM,WORD; 3、基于Open XML ,不用安装 MS Office,WPS 也可以生产 DOCX 格式的文件;
oraclesql判断值为空-Oracle-sqlserver的空值(null)判断.pdf
最新的正式发布版sqldeveloper-21.4.3.063.0100-x64,无需安装oracle客户端,直接使用,超级方便,性能稳定,功能强大,比plsql不知强了多少,而且无盗版烦恼,全免费正版,可验证md5. MD5: 9e091ededcad4344e21c5fd...
Oracle SQL Developer 企业管理 Oracle12c连接工具,sqldeveloper18.2.0.183.1748-no-jre Oracle JDeveloper
非常详细的的整理了sql相关的知识、包括 数据类型、函数、查询、关联查询、高级查询、索引、约束、优化等知识
现有项目使用的oracle数据库,根据需求集成xxl-job,开源的xxl-job默认使用mysql,所以需要改造成oracle使用。这文档是sql的改造