Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A school weather station stores one record a day in a table Weather: the rainfall in millimetres, the temperature at noon in degrees Celsius and whether it was windy.
Day RainMm TempC Windy
Mon 0 15 FALSE
Tue 6 11 TRUE
Wed 12 9 TRUE
Thu 3 14 FALSE
Fri 0 19 FALSE
Sat 8 13 TRUE
Sun 1 18 FALSEWith AND a record passes only if both conditions are true; with OR it passes if at least one is true. A range is Field >= low AND Field <= high; outside a range is Field < low OR Field > high. Each part needs its own field name.
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. Inside. WHERE TempC >= 12 AND TempC <= 18. Mon (), Thu (), Sat () and Sun () pass: days. Sunday is exactly , so it passes <=.
Step 2. Outside. WHERE TempC < 12 OR TempC > 18. Tue (), Wed () and Fri () pass: days.
Check. , every day once.
Watch out. TempC < 12 AND TempC > 18 gives no days at all: no temperature is both.
Answer: (a) days. (b) days.
Log in to join the discussion.
Loading…