
PUZZLE 1 FISCAL YEAR TABLES 1
PUZZLE
1
FISCAL YEAR TABLES
Let’s write some CREATE TABLE statements that are as complete as
possible. This little exercise is important because SQL is a declarative
language and you need to learn how to specify things in the database
instead of in the code.
The table looks like this:
CREATE TABLE FiscalYearTable1
(fiscal_year INTEGER,
start_date DATE,
end_date DATE);
It stores date ranges for determining what fiscal year any given date
belongs to. For example, the federal government runs its fiscal year from
October 1 until the end of September. The scalar subquery you would
use to do this table lookup is:
(SELECT F1.fiscal_year ...