打卡第10天 -- 3S2A1P : 三道sql,2道算法,1道简答
sql-1
https://www.nowcoder.com/practice/aeaa116185f24f209ca4fa40e226de48?tpId=82&&tqId=29814&rp=1&ru=/ta/sql&qru=/ta/sql/question-ranking
在audit表上创建外键约束,其emp_no对应employees_test表的主键id。
(audit已经创建,需要先drop)
DROP TABLE audit;
CREATE TABLE audit(
EMP_no INT NOT NULL,
create_date datetime NOT NULL,
FOREIGN KEY(EMP_no) REFERENCES employees_test(ID));
sql-2
https://www.nowcoder.com/practice/51c12cea6a97468da149c04b7ecf362e?tpId=82&&tqId=29802&rp=1&ru=/ta/sql&qru=/ta/sql/question-ranking
对于表actor批量插入如下数据(不能有2条insert语句哦!)
insert into actor
values (1,'PENELOPE','GUINESS','2006-02-15 12:34:33'),
(2,'NICK','WAHLBERG','2006-02-15 12:34:33')
sql-3
https://www.nowcoder.com/practice/6d4a4cff1d58495182f536c548fee1ae?tpId=82&&tqId=29759&rp=1&ru=/ta/sql&qru=/ta/sql/question-ranking
查找薪水变动超过15次的员工号emp_no以及其对应的变动次数t
select a.*
from(
select s.emp_no,count(1) as t
from salaries s
group by s.emp_no
)as a
where t>15