失效链接处理 |
LintCode上的SQL教程对应的所有AC答案 PDF 下载
本站整理下载:
相关截图:
主要内容:
LEVEL1:
2045 · Output Hello LintCode
SELECT "Hello LintCode!";
2013 · Check the name of the teacher
SELECT `name` FROM `teachers`
2007 · Check course name and class size
SELECT `name`,`student_count` FROM courses
2009 · Query all teachers
SELECT * FROM `teachers`
1981 · Check the nationality of all teachers
SELECT DISTINCT country FROM teachers
2011 · Search for information on courses with more than 1000 participants
SELECT * FROM `courses` WHERE `student_count`>1000
2012 · Find course information for the course named Artificial Intelligence
SELECT * FROM courses WHERE `name`= 'Artificial Intelligence';
2017 · Inserting SQL course information into the course table
INSERT INTO courses VALUES (14,"SQL",200,"2021-02-25",1)
2021 · Insert teacher information into the specified column of the teachers table
INSERT INTO `teachers` (`name`,`email`,`age`,`country`) VALUES
('XiaoFu','XiaoFu@lintcode.com',20,'CN');
2020 · Update on the number of students choosing artificial intelligence
UPDATE `courses` SET `student_count`=500 WHERE `name`='Artificial
Intelligence'
2004 · Delete all courses until 2020
DELETE FROM `courses` WHERE `created_at`<'2020-1-1'
2019 · Delete all rows in the table
DELETE FROM `courses`
LEVEL2:
1952 · Query teachers over 20 years old
SELECT * FROM `teachers` WHERE `age`>20
1953 · Query the name of the Chinese teacher
SELECT `name` FROM `teachers` WHERE `country`='CN'
1957 · Inquire about courses starting before May 2020
SELECT `name`,`created_at` FROM `courses`
WHERE `created_at`>='2020-1-1' AND `created_at`<'2020-5-1'
1958 · Query the courses that meet the conditions taught by the specified teacher
SELECT * FROM `courses`
WHERE `teacher_id`=4 AND `student_count`>500
2001 · Query the course information of 'Web' or 'Big Data'
SELECT * FROM `courses`
WHERE `name`='Web'
OR `name`='Big Data';
2040 · Search for courses with an instructor id of less than 3 and more than 800 students
SELECT * FROM `courses`
WHERE (NOT `teacher_id`=3)
AND (`student_count`>800);
1960 · Query course information for a specific time
SELECT * FROM `courses`
WHERE created_at IN ('2021-1-1','2021-1-3')
1962 · Query courses with teacher id other than 1 and 3
SELECT `name` FROM courses WHERE `teacher_id` NOT IN(1,3)
1964 · Query for course information about the number of students within the specified range
SELECT * FROM `courses` WHERE `student_count` BETWEEN 50 AND 55;
1972 · Inquire about Chinese and Japanese teachers who have e-mail addresses
SELECT * FROM teachers
WHERE (email IS NOT NULL)
AND (`country`='CN' OR `country`='JP');
1974 · Query teacher information by email
SELECT `name`,`email` FROM `teachers`
WHERE `email` LIKE '%@qq.com';
1982 · Check the age of teachers and sort them in ascending order
SELECT DISTINCT `age` FROM `teachers`
ORDER BY `age`;
1977 · Sorted by age of Chinese teachers in descending order
SELECT * FROM `teachers`
WHERE `country`='CN'
ORDER BY `age` DESC;
1980 · Search for the oldest Chinese teacher
SELECT * FROM `teachers`
WHERE `country`='CN'
ORDER BY `age` DESC
LIMIT 1;
|