zoukankan      html  css  js  c++  java
  • Oracle DQL查询语言整理

     1 select * from t_hq_ryxx;
     2 
     3 select nianl, xingm from t_hq_ryxx;
     4 
     5 select nianl as 年龄, xingm as 姓名 from t_hq_ryxx t;
     6 
     7 select nianl 年龄 from t_hq_ryxx;
     8 
     9 select nianl || xingm as 年龄和姓名 from t_hq_ryxx;
    10 
    11 select nianl as hhh,t.* from t_hq_ryxx t order by nianl desc ;--排序
    12 
    13 select nianl as hhh,t.* from t_hq_ryxx t order by xingb desc ,bum desc;
    14 
    15 select nianl,xingm,bum,xingb from t_hq_ryxx t order by bum desc nulls last,xingb;
    16 
    17 select * from t_hq_ryxx order by 3;
    18 
    19 select nianl,gongz, (nianl+gongz)as g from t_hq_ryxx order by (gongz||nianl);
    20 
    21 --去重复
    22 select distinct bum from t_hq_ryxx;
    23 
    24 select distinct bum,xingb from t_hq_ryxx;
    25 
    26 select * from t_hq_ryxx;
    27 
    28 
    29 select * from t_hq_ryxx where xingb = '1 'and bum = '102';
    30 
    31 select * from t_hq_ryxx where (bum = '101' or bum = '102') and xingb = '2'and nianl >'40' ;
    32 
    33 select * from t_hq_ryxx where bum is not null;
    34 
    35 --模糊查询 %表示通配符
    36 
    37 select * from t_hq_ryxx where xingm like '三%'
    38 
    39 select * from t_hq_ryxx where xingm like '%儿'
    40 
    41 select * from t_hq_ryxx where xingm like '%三%'
    42 
    43 select * from t_hq_ryxx where gongz <any (select pingjgz from t_hq_bm);
    44 
    45 --值得范围
    46 select * from t_hq_ryxx where nianl in ('33','58');
    47 
    48 select * from t_hq_ryxx where nianl ='33' or nianl = '58';
    49 
    50 --区间范围
    51 
    52 select * from t_hq_ryxx where gongz between 40 and 100;
    53 
    54 select * from t_hq_ryxx where gongz >=40 and gongz <= 100;
    55 
    56 --子查询
    57 select * from t_hq_ryxx where bum in (select bumbm from t_hq_bm where lianxdh = '10086');
    58 
    59 --大于最小值,小于最大值
    60 
    61 select * from t_hq_ryxx where gongz >any (select pingjgz from t_hq_bm);
    62 
    63 --大于最大值,小于最小值
    64 
    65 
    66 select * from t_hq_ryxx where gongz >all (select pingjgz from t_hq_bm);
    67 
    68 --分组 多种形式
    69 select bum from t_hq_ryxx group by bum;
    70 
    71 select bum,count(1) as 数量 from t_hq_ryxx group by bum;
    72 
    73 select bum,count(1) as 数量,sum (gongz) as 合计 from t_hq_ryxx group by bum;
    74 
    75 select bum,count(1) as 数量,avg(gongz) as 平均值 from t_hq_ryxx group by bum;
    76 
    77 select nianl, bum,count(1) as 数量,avg(gongz) as 平均值 from t_hq_ryxx group by nianl, bum;
    78 
    79 select bum,count(1) as 数量,avg(gongz) as 平均值 from t_hq_ryxx group by bum having avg(gongz)>60;
    80 
    81 
    82  
  • 相关阅读:
    IMP-00009: 导出文件异常结束
    Unknown collation: 'utf8mb4_unicode_ci'
    从 github 执行 git clone 一个大的项目时提示 error: RPC failed
    PHP 中获取当前时间[Datetime Now]
    wordpress 常用函数 checked(),selected(),disabled()
    github 有名的问题【ERROR: Permission to .git denied to user】
    SSH 基础
    mixed content 混合内容
    nginx gzip 模块配置
    markdown 书写表格
  • 原文地址:https://www.cnblogs.com/ymf123/p/4915714.html
Copyright © 2011-2022 走看看