牛客網sqlプログラミング問題
2470 ワード
1. 題目は、遅くとも入社した従業員を検索するすべての情報CREATE TABLE 问题解答: タイトル説明 入社時間最下位3位の社員全情報CREATE TABLE 问题解答:
employees
(emp_no
int(11)NOT NULL、birth_date
date NOT NULL、first_name
varchar(14)NOT NULL、last_name
varchar(16)NOT NULL、gender
char(1)NOT NULL、hire_date
date NOT NULL、PRIMARY KEY(emp_no
);select *
from employees
order by hire_date desc
limit 0,1
select * from employees
where hire_date =
(select max(hire_date) from employees)
employees
(emp_no
int(11)NOT NULL、birth_date
date NOT NULL、first_name
varchar(14)NOT NULL、last_name
varchar(16)NOT NULL、gender
char(1)NOT NULL、hire_date
date NOT NULL、PRIMARY KEY(emp_no
);select *
from
employees
where hire_date=(select distinct hire_date
from employees
order by hire_date desc
limit 2,1);
select * from employees e1
where 2=(select count(*)
from employees e2
where e1.hire_date < e2.hire_date);