Plan-of-SQLs Interface TN

Task: Verify the Statement against the Table

Statement: the volume that has 1 disc , 4 episodes , and a region 1 of may 30 , 2006 is volume 5

Table: none

volume discs episodes region_1 region_2 region_4
1 1 4 2006-01-31 2007-02-19 2007-03-15
2 1 4 2006-03-28 2007-06-04 2007-07-05
3 1 4 2006-05-30 2007-09-03 2008-03-13
4 1 4 2006-07-18 2008-02-18 2008-06-19
5 1 4 2006-09-19 2008-05-26 2009-03-05
Generating plan to answer the query...

Generated steps

Step 1: Select rows where 'discs' is 1.

Step 2: Select rows where 'episodes' is 4.

Step 3: Select rows where 'region_1' is '2006-05-30'.

Step 4: Use a `CASE` statement to return TRUE if the number of rows is equal to 1 and the 'volume' is 5, otherwise return FALSE.

Step 1: Select rows where 'discs' is 1.

SQL command for the step:

SELECT * FROM table_sql WHERE discs = 1;
volume discs episodes region_1 region_2 region_4
1 1 4 2006-01-31 2007-02-19 2007-03-15
2 1 4 2006-03-28 2007-06-04 2007-07-05
3 1 4 2006-05-30 2007-09-03 2008-03-13
4 1 4 2006-07-18 2008-02-18 2008-06-19
5 1 4 2006-09-19 2008-05-26 2009-03-05

Step 2: Select rows where 'episodes' is 4.

SQL command for the step:

SELECT * FROM table_sql WHERE episodes = 4;
volume discs episodes region_1 region_2 region_4
1 1 4 2006-01-31 2007-02-19 2007-03-15
2 1 4 2006-03-28 2007-06-04 2007-07-05
3 1 4 2006-05-30 2007-09-03 2008-03-13
4 1 4 2006-07-18 2008-02-18 2008-06-19
5 1 4 2006-09-19 2008-05-26 2009-03-05

Step 3: Select rows where 'region_1' is '2006-05-30'.

SQL command for the step:

SELECT * FROM table_sql WHERE region_1 = '2006-05-30';
volume discs episodes region_1 region_2 region_4
1 1 4 2006-01-31 2007-02-19 2007-03-15
2 1 4 2006-03-28 2007-06-04 2007-07-05
3 1 4 2006-05-30 2007-09-03 2008-03-13
4 1 4 2006-07-18 2008-02-18 2008-06-19
5 1 4 2006-09-19 2008-05-26 2009-03-05

Step 4: Use a `CASE` statement to return TRUE if the number of rows is equal to 1 and the 'volume' is 5, otherwise return FALSE.

SQL command for the step:

SELECT CASE WHEN COUNT(*) = 1 AND MAX(volume) = 5 THEN TRUE ELSE FALSE END AS verification FROM table_sql;
volume discs episodes region_1 region_2 region_4
3 1 4 2006-05-30 2007-09-03 2008-03-13

Verification:

The statement is FALSE