![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Oracle
a1008223
这个作者很懒,什么都没留下…
展开
-
oracle 取A表的数据,关联B表的id最小值
1.先关联出数据作为临时表a,取出最小值,然后将剩余的行数去掉最小值的行,即可 with a as (SELECT A.cus_No FROM A , B where B.rel_org_no(+)=A.cus_no and t.Stop_Flag='N' ) SELECT a.* from a where usr_id in (select min(usr_Id) f...原创 2011-09-29 15:18:30 · 741 阅读 · 0 评论 -
sj22
Organizations 字段名 含义 类型 缺省值 备注 Org_ID 机构编号 VC(20) PK Org_Name 机构名称 VC(500) 必填项 Org_Type 机构类别 VC(2) 0 中心 User Usr_ID 用户编号 VC(10) PK Usr_Name 用户姓名 VC(20) ' ' 必填项 Usr_LoginID 登录名 VC(20)...原创 2013-01-09 21:37:07 · 111 阅读 · 0 评论 -
delete 之后shrink table 释放表空间
http://blog.csdn.net/tianlesoftware/article/details/4764254 SQL> alter table my_objects enable row movement; Table altered SQL> alter table my_objects shrink space; Table altered原创 2013-05-07 15:35:43 · 271 阅读 · 0 评论 -
格式化数字
to_number(ordd_qty,'fm9999990.09999')原创 2012-02-12 15:40:35 · 105 阅读 · 0 评论 -
case when 统计
with a as( select distinct t.cus_type3, sum(case when c.cat_no like 'A'||'%' then c.con_amt else 0 end) over (partition by t.cus_type3) ANUM3 , sum(case when c.cat_no like 'B'||'%' then c.con_a...原创 2011-11-24 14:41:29 · 93 阅读 · 0 评论 -
oracle 存BLOB和读取
public void savaSoftFile(InputStream inputStream,String userid) { // 传的是存入数据库图片的id Connection conn=getConn(); Statement st = null; BLOB blob = null; // 图片类型 Ou...原创 2011-11-24 10:51:49 · 254 阅读 · 0 评论 -
用户权限授权
with d as (select t.menu_no , b.usr_id from menu_grant t, grp_members b where t.obj_type='G' and t.obj_no = b.grp_no union select t.menu_no , b.usr_id from menu_grant t, users b wh...原创 2011-11-19 12:44:58 · 101 阅读 · 0 评论 -
分组后取最大值关联其他表
select * from( select a.id ,(select b.name from b where b.id=a.id) name,row_num() over (partition by dep order by add_date desc) rn ) where rn=1; 关联表放在上边,做等值关联,分组会出问题...原创 2011-11-14 15:16:01 · 173 阅读 · 0 评论 -
触发器创建
create trigger TestTriggerInsert on Test for insert as insert into TempLog(tablename,pks,adddate,isUsed,options) select 'Test', 'id='+i.id, getdate(), 'N', 'update' from Test t, inserted i ...原创 2012-02-01 15:32:57 · 83 阅读 · 0 评论 -
表字段修改备注
select t.TABLE_NAME 表名, t.COLUMN_ID 序号, t.COLUMN_NAME 字段名, t.DATA_TYPE 类型, t. DATA_LENGTH 长度, decode(t.NULLABLE,'N','PK','') 是否为空, b.COMMENT...原创 2011-12-27 20:39:40 · 355 阅读 · 0 评论 -
分组取最大值统计,过滤
汇率保存,千分之5以内的,按照日期,币种,汇率,汇率浮动分组。 首先分组,按照日期,币种,汇率,汇率浮动,然后分组统计(日期,币种,汇率)= 1的并且, 浮动范围在千分5以内。 如果有2条汇率,一条记录大于千分之5,一条记录小于千分之5,分组统计数目就大于1,就过滤掉。 如果汇率正常的且有多条,然后取max 最大值。 select c.trans_date, c.impor...原创 2016-03-14 16:46:24 · 289 阅读 · 0 评论