zoukankan      html  css  js  c++  java
  • oracle课堂随笔--第十一天

    排序:

    SQL> select last_name, salary from employees order by salary;

    SQL> select last_name, salary from employees order by salary desc;大到小

    SQL> select last_name, salary from employees order by last_name;

    SQL> select last_name, hire_date from employees order by hire_date;

    SQL> select last_name, salary, commission_pct from employees order by salary desc, commission_pct desc;

    SQL> select last_name, salary*12*(1+commission_pct) from employees order by 2;

    SQL> select last_name, salary*12*(1+commission_pct) total_salary from employees order by total_salary;

    单行函数

    SQL> select upper(first_name), lower(last_name), length(last_name) from employees;

    SQL> select (sysdate-hire_date)/7 from employees;

    SQL> select trunc((sysdate-hire_date)/30, 0) from employees;

    SQL> select trunc(months_between(sysdate,hire_date), 0) from employees;

    SQL> select sysdate+3650 from dual;

    SQL> select add_months(sysdate, 120) from dual;

    SQL> select next_day('2015-09-01', 'friday') from dual;

    SQL> select next_day('2015-10-01', 6) from dual;

    SQL> select last_day(sysdate) from dual;

    SQL> select round(to_date('2015-10-10','yyyy-mm-dd'), 'MONTH') from dual;

    SQL> select round(to_date('2015-10-16','yyyy-mm-dd'), 'MONTH') from dual;

    SQL> select round(to_date('2015-10-10','yyyy-mm-dd'), 'YEAR') from dual;

    SQL> select round(sysdate, 'DAY') from dual;

    类型转换和其他函,

    转换   to_char

    SQL> select to_char(salary, '$999,999.00') from employees;

    SQL> select last_name, to_char(hire_date, 'dd-Mon-RR') from employees;

    SQL> select to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss') from dual;

    SQL> select to_char(sysdate, 'yyyy-mm-dd hh:mi:ss AM') from dual;

    SQL> select last_name from employees where hire_date=to_date('2006-05-23', 'yyyy-mm-dd');

    SQL> select to_number('$123,456.78', '$999,999.00') from dual;

    elect last_name, job_id, salary,

    case job_id

      when 'IT_PROG' then salary+1000

      when 'SA_REP' then salary+1500

      when 'ST_CLERK' then salary+2000

      else salary

    end new_salary

    from employees;

    二 

    select last_name, job_id, salary,

    decode( job_id,

      'IT_PROG', salary+1000,

      'SA_REP',  salary+1500,

      'ST_CLERK', salary+2000,

      salary) new_salary

    from employees;

  • 相关阅读:
    mysql-5-aggregation
    mysql-4-functions
    mysql-3-orderby
    技术之心 | 云信和TA们携手打响防疫战
    疫情下的传统商企自救|4个Tips搭建销量过亿直播间
    那些2019年会爆发的泛娱乐黑科技风口
    流量难、获客难、增长难?增长黑客思维“解救”B端业务
    【翻译】Facebook全面推出Watch Party,可多人线上同看直播视频
    深入浅出聊一聊Docker
    C++写日志方法调试
  • 原文地址:https://www.cnblogs.com/Matilda/p/7252374.html
Copyright © 2011-2022 走看看