본문 바로가기
MySQL

sqlzoo.net 답 (SELECT from Nobel Tutorial)

https://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial

 

SELECT from Nobel Tutorial - SQLZOO

nobel yr subject winner 1960 Chemistry Willard F. Libby 1960 Literature Saint-John Perse 1960 Medicine Sir Frank Macfarlane Burnet 1960 Medicine Peter Madawar ... nobel Nobel Laureates We continue practicing simple SQL queries on a single table. This tutor

sqlzoo.net

 

SELECT from Nobel Tutorial

-- no1

SELECT yr, subject, winner FROM nobel WHERE yr = 1950


-- no2

SELECT winner FROM nobel
WHERE yr = 1962 AND subject = 'Literature'


-- no3

SELECT yr, subject FROM nobel
where winner = 'Albert Einstein'

 

-- no4

select winner from nobel
where subject = 'Peace' and yr >= 2000 

 

-- no5

select yr, subject, winner
from nobel
where subject = 'Literature' and
yr between 1980 and 1989;


--no6

select * from nobel
where winner in ('Theodore Roosevelt', 'Woodrow Wilson', 'Jimmy Carter', 'Barack Obama')


-- no7

select winner
from nobel
where winner like 'John%';
select winner
from nobel
where winner regexp '^John';


--no9

select yr, subject, winner
from nobel
where yr = 1980 and
subject not in ('Chemistry', 'Medicine');


--no10

select *
from nobel
where (subject  = 'medicine' and yr < 1910) or (subject = 'literature' and yr >= 2004)


--no11

select *
from nobel
where winner like 'peter gr%nberg'

 

--no12

select * from nobel
where winner = 'EUGENE O\'NEILL'

 

--no13

select winner, yr, subject
from nobel
where winner like 'sir%'
order by yr desc, winner


--no14

SELECT winner, subject
FROM nobel
WHERE yr=1984
ORDER BY subject IN ('Physics','Chemistry'), subject, winner