Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A school books rooms from this table.
RoomNo Seats Projector
R1 30 TRUE
R2 12 FALSE
R3 24 TRUE
R4 8 FALSE
R5 32 FALSEWHERE keeps only the records for which the condition is true. The operators are =, <>, >, <, >= and <=. Text goes in quotes, numbers do not, and a Boolean field is compared with TRUE or FALSE. The field in the condition need not be selected.
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 script.
SELECT RoomNo
FROM Rooms
WHERE Projector = FALSE;The output:
RoomNo
R2
R4
R5Step 2. Count. records: R2, R4 and R5.
Step 3. The seats. seats. The next course shows how SQL adds them up with SUM.
Answer: (a) SELECT RoomNo FROM Rooms WHERE Projector = FALSE; (b) records. (c) seats.
Log in to join the discussion.
Loading…