Plan-of-SQLs Interface TP

Task: Verify the Statement against the Table

Statement: this person 's lowest yearly earnings between 1998 and 2005 was 0

Table: casey martin

year tournaments_played cuts_made wins best_finish earnings money_list_rank
1998 3 2 0 t - 23 37221 221
2000 29 14 0 t - 17 143248 179
2001 2 0 0 cut 0 n / a
2002 3 0 0 cut 0 n / a
2003 1 0 0 cut 0 n / a
2004 2 2 0 t - 69 15858 n / a
2005 1 1 0 t - 65 10547 n / a
Generating plan to answer the query...

Generated steps

Step 1: Order the table by 'earnings' in ascending order.

Step 2: Select row number 1.

Step 3: Select rows where 'earnings' is 0.

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

Step 1: Order the table by 'earnings' in ascending order.

SQL command for the step:

SELECT * FROM table_sql ORDER BY earnings ASC;
year tournaments_played cuts_made wins best_finish earnings money_list_rank
1998 3 2 0 t - 23 37221 221
2000 29 14 0 t - 17 143248 179
2001 2 0 0 cut 0 n / a
2002 3 0 0 cut 0 n / a
2003 1 0 0 cut 0 n / a
2004 2 2 0 t - 69 15858 n / a
2005 1 1 0 t - 65 10547 n / a

Step 2: Select row number 1.

SQL command for the step:

SELECT * FROM table_sql LIMIT 1;
year tournaments_played cuts_made wins best_finish earnings money_list_rank
2001 2 0 0 cut 0 n / a
2002 3 0 0 cut 0 n / a
2003 1 0 0 cut 0 n / a
2005 1 1 0 t - 65 10547 n / a
2004 2 2 0 t - 69 15858 n / a
1998 3 2 0 t - 23 37221 221
2000 29 14 0 t - 17 143248 179

Step 3: Select rows where 'earnings' is 0.

SQL command for the step:

SELECT * FROM table_sql WHERE earnings = 0;
year tournaments_played cuts_made wins best_finish earnings money_list_rank
2001 2 0 0 cut 0 n / a

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

SQL command for the step:

SELECT CASE WHEN COUNT(*) = 1 THEN TRUE ELSE FALSE END AS verification FROM table_sql;
year tournaments_played cuts_made wins best_finish earnings money_list_rank
2001 2 0 0 cut 0 n / a

Verification:

The statement is TRUE