zoukankan      html  css  js  c++  java
  • oracle sql 高级

    1  时间
     
    如果是从当前时间到前一个月的这个时候之间的记录总条数:
     
    select count(1)
      from uis_md_stcustom u
     where firsttime between add_months(sysdate,-1) and sysdate; 
     
     
    如果是求当前时间的前面一个月的内的记录总条数:
     
    select count(1)
      from uis_md_stcustom u
     where to_char(firsttime,'mm') = to_char(add_months(sysdate,-1),'mm');
     
     
    2 IN/ANY
     
    IN- Equal toany member in the list
    ANY- Compare value to**each** value returned by the subquery
    ALL- Compare value to**EVERY** value returned by the subquery
    
    <ANY()- less than maximum
    >ANY()- more than minimum
    =ANY()- equivalent toIN>ALL()- more than the maximum
    <ALL()- less than the minimum

    eg:

    Find the employees who earn the same salary as the minimum salary for each department-

    SELECT last_name, salary,department_id
    FROM employees
    WHERE salary IN(SELECT MIN(salary)FROM employees
                     GROUPBY department_id);

    Employees who are not IT Programmers and whose salary is less than that of any IT programmer-

    SELECT employee_id, last_name, salary, job_id
    FROM employees
    WHERE salary <ANY(SELECT salary
                     FROM employees
                     WHERE job_id ='IT_PROG')AND job_id <>'IT_PROG';

    Employees whose salary is less than the salary ofall employees with a job ID of IT_PROG and whose job is not IT_PROG-

    SELECT employee_id,last_name, salary,job_id
    FROM employees
    WHERE salary <ALL(SELECT salary
                     FROM employees
                     WHERE job_id ='IT_PROG')AND job_id <>'IT_PROG;
  • 相关阅读:
    过渡效果
    生命周期
    事件处理
    列表的搜索和排序
    DotNetBar for Windows Forms 12.1.0.0_冰河之刃重打包版 原创发布
    DotNetBar for Windows Forms 11.8.0.8冰河之刃重打包版
    闲读
    POJ 3253 Fence Repair 贪心 优先级队列
    POJ 2431 Expedition 贪心 优先级队列
    优先级队列-堆-STL实现
  • 原文地址:https://www.cnblogs.com/itech/p/3157654.html
Copyright © 2011-2022 走看看