38

Temporal Queries

Temporal data is the hardest type of data for people to handle conceptually. Perhaps time is difficult because it is dynamic and all other data types are static or perhaps because time allows multiple parallel events. This is an old puzzle that still catches people.

If a hen and a half lays an egg and a half in a day and a half, how many eggs will five hens lay in six days? Do not look at the rest of the page—try to answer the question in your head.

Suppose two hens lay four eggs in three days. That means that each hen laid two eggs during those three days, so each hen lays 2/3 of an egg per day. Now if you had five hens and six days, they would lay five times as many eggs per day, totaling 10/3 per day; multiply that by 6 ...

Get Joe Celko's SQL for Smarties, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.