单表查询

博客展示了一系列SQL查询语句,包括基本的SELECT查询、带条件的查询、使用列别名、处理NULL值的函数(如NVL、NVL2、DECODE)、字符串替换函数,还有CASE语句进行数据分组统计等,体现了SQL在数据查询和处理方面的应用。

–conn scott/tiger
select * from emp;
select * from emp where (1=1);
select * from ( select empno,sal 工资 from emp) where 工资<1000;–列别名在select以后才有效;
select * from emp where comm is null;
–coalesce(a,b,c,d,e,f);unllif(‘a’,‘a’)返回null,unllif(‘a’,‘b’)返回a;
SQL> select nvl(4,‘abc’) from dual;
ORA-01722: 无效数字
SQL> select nvl(to_char(4),‘abc’) from dual; --nvl的二个参数数据类型要一致。
select nvl(comm,0) from emp;
select nvl2(comm,comm,9999) from emp;
select decode(comm,null,9999,comm) from emp;
select replace(‘abc’,‘a’,null) from dual;
select ‘insert into t318(dates) values (’||hiredate||’)’ from emp;
select 档次,count() as 人数 from (select (case when sal<=1000 then ‘0000-1000’
when sal<=2000 then ‘1000-2000’
when sal<=3000 then ‘2000-3000’
when sal<=4000 then ‘3000-4000’
else ‘high’ end) as 档次 from emp) group by 档次 order by 1;
select rownum,emp.
from emp where rownum<5;
--case floor((to_char(stat_date, ‘mi’)) / 15) when 0 then to_char(stat_date, ‘yyyy.mm.dd hh24’) || ‘:00:00’
 --                  when 1 then to_char(stat_date, ‘yyyy.mm.dd hh24’) || ‘:15:00’

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值