SQLZOO : SELECT from Nobel Tutorial

Zero·2022년 4월 12일
0

MySQL

목록 보기
3/5
post-thumbnail

sqlzoo에 나오는 문제들이다.
자세한 사항은 아래의 링크를 클릭해보자.

https://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial

  1. Winners from 1950
select * from nobel
 where yr = 1950;
  1. 1962 Literature
select winner
 from nobel
 where yr = 1962
  and subject ='Literature';
  1. Albert Einstein
select yr, subject 
 from nobel
 where winner = 'Albert Einstein';
  1. Recent Peace Prizes
select winner
 from nobel
 where subject = 'peace'
 and yr >= 2000;
  1. Literature in the 1980's
select *
 from nobel
 where subject = 'literature'
 and yr between 1980 and 1989;
  1. Only Presidents
select *
 from nobel
 where winner in ('Theodore Roosevelt', 'Woodrow Wilson', 'Jimmy Carter', 'Barack Obama');
  1. John
select winner
 from nobel
 where winner like 'john%';
  1. Chemistry and Physics from different years
SELECT *
FROM nobel
WHERE (subject = 'physics' and yr = 1980) or (subject = 'chemistry' and yr = 1984);
  1. Exclude Chemists and Medics
select *
 from nobel
 where yr = 1980
 and subject not in ('chemistry', 'medicine');
  1. Early Medicine, Late Literature
select *
 from nobel
 where (subject = 'medicine' and yr < 1910)
  or (subject = 'literature' and yr >= 2004);
  1. Umlaut
select *
 from nobel
 where winner like 'peter%'
 and winner like '%berg'
  1. Apostrophe
select *
 from nobel
 where winner like 'EUGENE%'
 and winner like '%neill';
  1. Knights of the realm
select winner, yr, subject
 from nobel
 where winner like 'sir%'
 order by yr desc, winner;
  1. Chemistry and Physics last
    The expression subject IN ('Chemistry','Physics') can be used as a value - it will be 0 or 1.

Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.

select winner, subject
 from nobel
where  yr = 1984
order by subject in ('physics', 'chemistry'), subject, winner;

14번 문제... 분명 맞게 썼는데 정답처리는 안해줬다...
왜지...?

profile
코딩 일기

0개의 댓글