----给表的字段添加描述
COMMENT ON COLUMN 数据库名称.表名.表字段 IS '字段描述';

---设置自动增长

CREATE SEQUENCE emp_sequence   

INCREMENT BY 1 -- 每次加几个   

START WITH 1 -- 从1开始计数   

NOMAXVALUE -- 不设置最大值   

NOCYCLE -- 一直累加,不循环   

NOCACHE -- 不建缓冲区

------给表增加一个字段
alter table 表名 add 字段名 数据类型(类型长度);

------给表的某个字段设置默认值
update GOODSINFO set GOODSINFO.ISBATCH=1;

----删除表中的某个字段
ALTER TABLE 表名称 DROP COLUMN 删除的字段名称;

----删除表
drop table 表名

---修改字段类型

alter table tb modify (name nvarchar2(20));

----创建视图

create view V_GOODSINFO as  查询语句

---给字段0和1设置名字

select u.id,u.realname,U.SEX,
( case u.sex
when 1 then '男'

when 2 then '女'
else '空的'
END
) 性别
from users
u;

---按月分组

select to_char(exportDate,'yyyy-mm'),sum(amount) from table1 group

by to_char(exportDate,'yyyy-mm')

--按季度分组

select to_char(exportDate,'yyyy-Q'),sum(amount) from table1 group

by to_char(exportDate,'yyyy-Q')

--按年分组

select to_char(exportDate,'yyyy'),sum(amount) from table1 group by

to_char(exportDate,'yyyy');

--按月份统计分组

select
b.MATERIALname, --商品名称
b.GOODSPEC, -- 规格
b.SAFETYONE, --编码
a.OUTOFSTORAGETYPE, --出入库类型
sum(a.INNUM), --入库总数
sum(a.OUTNUM), --出库总数
sum(((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.INNUM)) as inmoney, --入库总金额
sum(((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID) * a.OUTNUM)) as outmoney, --出库总金额
to_char(a.CREDATE,'yyyy-mm')
from UNMATERIAL_Order a ,UNMATERIAL b
where to_char(a.CREDATE,'yyyy')=to_char(sysdate,'yyyy') and a.MATERIAL_id = b.MATERIAL_id
group by to_char(a.CREDATE,'yyyy-mm'),b.MATERIALname,b.GOODSPEC,b.SAFETYONE,a.OUTOFSTORAGETYPE

---- 将 数量、金额、根据十二个月进行统计

select
b.MATERIALname, --商品名称
b.GOODSPEC, -- 规格
b.SAFETYONE, --编码
a.UNMATERIAL_ID,
sum(decode(to_char(a.CREDATE,'mm'),'01',a.INNUM,0)) INNUM1,
sum(decode(to_char(a.CREDATE,'mm'),'02',a.INNUM,0)) INNUM2,
sum(decode(to_char(a.CREDATE,'mm'),'03',a.INNUM,0)) INNUM3,
sum(decode(to_char(a.CREDATE,'mm'),'04',a.INNUM,0)) INNUM4,
sum(decode(to_char(a.CREDATE,'mm'),'05',a.INNUM,0)) INNUM5,
sum(decode(to_char(a.CREDATE,'mm'),'06',a.INNUM,0)) INNUM6,
sum(decode(to_char(a.CREDATE,'mm'),'07',a.INNUM,0)) INNUM7,
sum(decode(to_char(a.CREDATE,'mm'),'08',a.INNUM,0)) INNUM8,
sum(decode(to_char(a.CREDATE,'mm'),'09',a.INNUM,0)) INNUM9,
sum(decode(to_char(a.CREDATE,'mm'),'10',a.INNUM,0)) INNUM10,
sum(decode(to_char(a.CREDATE,'mm'),'11',a.INNUM,0)) INNUM11,
sum(decode(to_char(a.CREDATE,'mm'),'12',a.INNUM,0)) INNUM12,

sum(decode(to_char(a.CREDATE,'mm'),'01',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY1,
sum(decode(to_char(a.CREDATE,'mm'),'02',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY2,
sum(decode(to_char(a.CREDATE,'mm'),'03',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY3,
sum(decode(to_char(a.CREDATE,'mm'),'04',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY4,
sum(decode(to_char(a.CREDATE,'mm'),'05',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY5,
sum(decode(to_char(a.CREDATE,'mm'),'06',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY6,
sum(decode(to_char(a.CREDATE,'mm'),'07',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY7,
sum(decode(to_char(a.CREDATE,'mm'),'08',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY8,
sum(decode(to_char(a.CREDATE,'mm'),'09',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY9,
sum(decode(to_char(a.CREDATE,'mm'),'10',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY10,
sum(decode(to_char(a.CREDATE,'mm'),'11',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY11,
sum(decode(to_char(a.CREDATE,'mm'),'12',((select APRICE from UNMATERIAL where KEYID=a.MATERIAL_ID)* a.INNUM),0)) INMONEY12
from UNMATERIAL_Order a ,UNMATERIAL b

where to_char(a.CREDATE,'yyyy')=to_char(sysdate,'yyyy') and a.MATERIAL_id = b.MATERIAL_id and a.OUTOFSTORAGETYPE='入库'
group by to_char(a.CREDATE,'yyyy-mm'),b.MATERIALname,b.GOODSPEC,b.SAFETYONE,a.UNMATERIAL_ID

												

关于oracle的相关基础语句的更多相关文章

  1. 【RAC】RAC相关基础知识

    [RAC]RAC相关基础知识 1.CRS简介    从Oracle 10G开始,oracle引进一套完整的集群管理解决方案—-Cluster-Ready Services,它包括集群连通性.消息和锁. ...

  2. JAVA相关基础知识

    JAVA相关基础知识 1.面向对象的特征有哪些方面 1.抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只是选择其中的一部分, ...

  3. Linux 相关基础笔记

    html,body { } .CodeMirror { height: auto } .CodeMirror-scroll { } .CodeMirror-lines { padding: 4px 0 ...

  4. linux设备驱动归纳总结(二):模块的相关基础概念【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-59415.html linux设备驱动归纳总结(二):模块的相关基础概念 系统平台:Ubuntu 10 ...

  5. linux设备驱动归纳总结(一)内核的相关基础概念【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-59413.html linux设备驱动归纳总结(一):内核的相关基础概念 xxxxxxxxxxxxxx ...

  6. Oracle 性能相关常用脚本(SQL)

    在缺乏的可视化工具来监控数据库性能的情形下,常用的脚本就派上用场了,下面提供几个关于Oracle性能相关的脚本供大家参考.以下脚本均在Oracle 10g测试通过,Oracle 11g可能要做相应调整 ...

  7. Oracle Applications DBA 基础(一)

    1.引子 2014年9月13日 20:33 <oracle Applications DBA 基础>介绍Oracle Applications R12的系统架构, 数据库后台及应用系统的基 ...

  8. Oracle数据库操作---基础使用(二)

    此篇承接上一篇的基本原理,继续展开学习,本篇主要面向数据的使用和管理,也就是开发者常用的基础语句,开始喽…… >>>对整表的操作 >创建表   关键字 Create creat ...

  9. Oracle数据库,基础知识

    1.Oracle的五大约束条件: 1 主键  primary key2 外键  foreign key,3 唯一  unique,4 检测  check5 非空  not null 实例运用: -- ...

随机推荐

  1. CSS实现垂直水平居中

    HTML结构: <div class="wrapper"> <div class="content"></div> < ...

  2. 1、webservice的简单使用

    1.新建一个web端项目 2.点击添加项,选择web服务 3.在已经建好的项目中写一个方法 4.发布(发布方法选文件系统,web需要管理员权限) 生成文件夹: 5.配置IIS(略) 6.调用webse ...

  3. Conntect Bluetooth devices in iOS.

    I understand that the External Accessory framework in iOS 3.0 and later will allow my application to ...

  4. tensorflow3

    参考文献:tensorflow_manual_cn.pdf 一.tensorflow和caffe对应: graph-->.prototxt定义的网络结构 session-->solver( ...

  5. 诺基亚XL中Intent.ACTION_VIEW无效的问题

    今天测试播放视频的时候,发现在诺基亚XL机型里不能弹出视频应用列表. 我的代码是: Intent intent = new Intent(Intent.ACTION_VIEW); intent.set ...

  6. A candidate solution for Java Web Application - current session

    Motivation Do it once, resue for ever. Audience myself, Java Web developers Scope 应用案例 图书借阅系统 阶段1需求: ...

  7. HttpSendRequest同步请求不返回

    HttpSendRequest是基于socket实现的 在工作过程中发现当发送请求时 1.当网络没有连接时 会同步返回失败 2.当发送请求时 把网线拔下也是会同步返回失败 3.但是第三种情况 发送请求 ...

  8. python中的if __name__ == '__main__' what hell is it?

    python中的if __name__ == '__main__' what hell is it? python认为一切模块都可能被执行或者被import 如果一个模块是被import导入的,那么该 ...

  9. 【Jenkins】jenkins简单搭建并执行任务

    part 1  jenkins用户名的配置(gerrit 2.11) #安装jenkins $ sudo apt-get install jenkins #为jenkins用户设定密码 $ sudo ...

  10. bash的操作环境[转]

          Bash Shell 的操作环境: 是否记得我们登陆主机的时候,屏幕上头会有一些说明文字,告知我们的 Linux 版本啊什么的, 还有,登陆的时候我们还可以给予用户一些信息或者欢迎文字呢. ...