Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A film club keeps this table, Films.
FilmID Title Rating Minutes
V1 Moon Run PG 94
V2 Red Fox U 81
V3 Cold Case 15 112
V4 Sky High 12 99Complete the script so that its output is the rating and then the film ID of every film.
SELECT ________, ________
FROM ________;A query starts SELECT (the fields to output, with commas between them, in the order you want) and FROM (the table). A semicolon ends it. With no condition, every record is output, in the order of the table.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. The fields, in order. The rating comes first, then the film ID: Rating, FilmID.
Step 2. The table. Films.
Answer: SELECT Rating, FilmID FROM Films;. Its first output row is PG, V1.
Log in to join the discussion.
Loading…