zoukankan      html  css  js  c++  java
  • 11.18

    一、题目描述

    查找薪水变动超过15次的员工号emp_no以及其对应的变动次数t
    CREATE TABLE `salaries` (
    `emp_no` int(11) NOT NULL,
    `salary` int(11) NOT NULL,
    `from_date` date NOT NULL,
    `to_date` date NOT NULL,
    PRIMARY KEY (`emp_no`,`from_date`));

    答案

    select emp_no,count(to_date) as t from salaries 
    group by emp_no
    having t > 15

    having    为分组后的条件判断

    二、题目描述

    找出所有员工当前(to_date='9999-01-01')具体的薪水salary情况,对于相同的薪水只显示一次,并按照逆序显示
    CREATE TABLE `salaries` (
    `emp_no` int(11) NOT NULL,
    `salary` int(11) NOT NULL,
    `from_date` date NOT NULL,
    `to_date` date NOT NULL,
    PRIMARY KEY (`emp_no`,`from_date`));

    答案

    SELECT distinct(salary)  FROM salaries
    WHERE to_date='9999-01-01' 
    ORDER BY salary DESC

    distinct    去掉查询数据中重复的

  • 相关阅读:
    TortoiseGit
    申请成功
    web.xml文件中配置ShallowEtagHeaderFilter需注意的问题
    消息队列调研
    二阶段提交
    ACID CAP BASE介绍
    SQL NULL Values
    HTTPS原理
    ID生成器详解
    如何变得更聪明
  • 原文地址:https://www.cnblogs.com/wbf980728/p/13999939.html
Copyright © 2011-2022 走看看