1969 请编写 SQL 语句,查询课程表 courses 中开设在 2020 年内的所有课程信息。
输入数据
### courses
| id | name | student_count | created_at | teacher_id |
| :- | :------------------------ | :------------ | :----------- | :--------- |
| 1 | 'Advanced Algorithms' | 880 | '2020-06-01' | 4 |
| 2 | 'System Design' | 1350 | '2020-07-18' | 3 |
| 3 | 'Django' | 780 | '2020-02-29' | 3 |
| 4 | 'Big Data' | 700 | '2020-09-11' | 1 |
| 5 | 'Artificial Intelligence' | 1660 | '2018-05-13' | 3 |
| 6 | 'Java P6+' | 780 | '2019-01-19' | 3 |
| 7 | 'Data Analysis' | 500 | '2019-07-12' | 1 |
| 8 | 'Dynamic Programming' | 2000 | '2018-08-18' | 1 |
输出数据
| id | name | student_count | created_at | teacher_id |
| :- | :-------------------- | :------------ | :----------- | :--------- |
| 1 | 'Advanced Algorithms' | 880 | '2020-06-01' | 4 |
| 2 | 'System Design' | 1350 | '2020-07-18' | 3 |
| 3 | 'Django' | 780 | '2020-02-29' | 3 |
| 4 | 'Big Data' | 700 | '2020-09-11' | 1 |
正解:
select * from courses where extract(year from created_at)=2020
期望答案:
| id | name | student_count | created_at | teacher_id |
| :- | :-------------------- | :------------ | :----------- | :--------- |
| 1 | 'Advanced Algorithms' | 880 | '2020-06-01' | 4 |
| 2 | 'System Design' | 1350 | '2020-07-18' | 3 |
| 3 | 'Django' | 780 | '2020-02-29' | 3 |
| 4 | 'Big Data' | 700 | '2020-09-11' | 1 |