Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #14 Portable code #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions SQLZOO_solutions.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,11 @@ SELECT winner, yr, subject FROM nobel
14.
```sql
SELECT winner, subject
FROM nobel
WHERE yr=1984
ORDER BY subject in ('Chemistry','Physics'), subject, winner
FROM nobel
WHERE yr=1984
ORDER BY
CASE WHEN subject IN ('Physics', 'Chemistry') THEN 1 ELSE 0 END,
subject, winner
```
## SELECT in SELECT
1.
Expand Down Expand Up @@ -393,10 +395,11 @@ SELECT matchid, mdate, COUNT(*)
```
12.
```sql
SELECT matchid, mdate, COUNT(*) FROM goal
JOIN game ON (matchid=id)
WHERE teamid = 'GER'
GROUP BY matchid, mdate
SELECT matchid, mdate, COUNT(*)
FROM goal
JOIN game ON (matchid=id)
WHERE teamid = 'GER'
GROUP BY matchid, mdate
```
13.
```sql
Expand Down Expand Up @@ -522,7 +525,7 @@ SELECT title, COUNT(actorid) FROM casting
JOIN movie ON movieid = movie.id
WHERE yr = 1978
GROUP BY movieid, title
ORDER BY COUNT(actorid) DESC
ORDER BY COUNT(actorid) DESC , title
```
16.
```sql
Expand Down