zoukankan      html  css  js  c++  java
  • SQL-16 统计出当前各个title类型对应的员工当前薪水对应的平均工资。结果给出title以及平均工资avg。

    题目描述

    统计出当前各个title类型对应的员工当前薪水对应的平均工资。结果给出title以及平均工资avg。
    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`));
    CREATE TABLE IF NOT EXISTS "titles" (
    `emp_no` int(11) NOT NULL,
    `title` varchar(50) NOT NULL,
    `from_date` date NOT NULL,
    `to_date` date DEFAULT NULL);

    输入描述:

    输出描述:

    titleavg
    Engineer 94409.0
    Senior Engineer 69009.2
    Senior Staff 91381.0
    Staff 72527.0

    SQL:

    select t.title,avg(s.salary)
    from salaries s,titles t
    on t.emp_no=s.emp_no and s.to_date='9999-01-01' and t.to_date='9999-01-01'
    group by title
    

      

  • 相关阅读:
    友链QAQ
    快读
    树状数组
    构造(排列组合 插板法)
    字符串(string)(字符串相加)
    tarjan1
    魔术棋子(记忆化搜索)
    日期(csp2019)
    神奇的数字(magic)
    最佳调度问题(dfs)
  • 原文地址:https://www.cnblogs.com/kexiblog/p/10668572.html
Copyright © 2011-2022 走看看