zoukankan      html  css  js  c++  java
  • Oracle常用sql语句。

    最近工作中遇到了一些与oracle相关的问题,稍微整理一些工作中用到的SQL语句

    时间相关

    --查询距当前时间十分钟内的数据
    select sysdate -interval '10' minute as time from dual;
    
    --查询距当前时间十天内的数据
    select sysdate -interval '10' day as time from dual;
    
    --查询年月日 时分秒
    select to_char(sysdate,'yyyy-MM-dd HH24:mm:ss') as time from dual
    
    

    数值处理

    --小数点前的0不显示
    select to_char(0.58740,'fm99990.0099') from dual
    
    

    基本语法

    --case when then 语句
     select
        (case a.cjrlx 
                   when '1' then '0'
                   when '2' then '1'
                   when '3' then '2'
        end) as pasType --乘机人类型
            from kh_khddcjr a
    

    基本函数

        --decode函数的基本用法
        --M:男  F:女
        --相当于 if--else if--else 语句,如果性别是M,返回1,如果是F,返回2,如果还有其它的,可以接着写下去。感觉和case--when 挺像。
        select decode(k.xb,'M','1','F','2') as xb from  user k;
    
        
        --NVL函数
        --主要作用是从两个表达式返回一个非 null 值。
        --如果eExpression1的值是null,就返回eExpression2的值
        select NVL(k.xcdh,'000') as scdh from user k
    
    

    数据处理

        --查询某个字段是否有重复的
        select g.wxid,count(*) from BASE_GETWXID g group by g.wxid having count(*) > 1
    
  • 相关阅读:
    163国内镜像源
    一个简单的springboot项目
    springcloud概述
    final关键字
    springboot项目多模块打包
    Unity Shaderlab: Object Outlines
    生命周期
    Unity内置事件
    Win10输入指示器关掉后自动恢复的问题
    Unity Shader-后处理:景深
  • 原文地址:https://www.cnblogs.com/black-spike/p/8282377.html
Copyright © 2011-2022 走看看