Plan-of-SQLs Interface TN

Task: Verify the Statement against the Table

Statement: equestrian at the asian games has been located in a different city every year that it occurred except 1994 and 1998

Table: equestrian at the asian games

year location gold silver bronze
1982 new delhi nadia al - moutawaa jamila al - moutawaa bariaa salem al - sabbah
1986 seoul takashi tomura shuichi toki ryuzo okuno
1994 hiroshima konoshin kuwahara ryuzo okuno natya chantrasmi
1998 bangkok jin kanno sohn bong - gak quzier ambak fathil
2002 busan mikaela marã­a jaworski lee jin - kyung tadayoshi hayashi
2006 doha ali yousuf al - rumaihi jasmine chen - shao man joo jung - hyun
2010 guangzhou ramzy al duhami latifa al maktom khaled al - eid
Generating plan to answer the query...

Generated steps

Step 1: Select rows where 'year' is not 1994 or 1998.

Step 2: Extract the distinct values from the 'location' column then add column 'distinct_location' to existing table.

Step 3: Select rows where 'distinct_location' is greater than 1.

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

Step 1: Select rows where 'year' is not 1994 or 1998.

SQL command for the step:

SELECT * FROM table_sql WHERE year NOT IN (1994, 1998);
year location gold silver bronze
1982 new delhi nadia al - moutawaa jamila al - moutawaa bariaa salem al - sabbah
1986 seoul takashi tomura shuichi toki ryuzo okuno
1994 hiroshima konoshin kuwahara ryuzo okuno natya chantrasmi
1998 bangkok jin kanno sohn bong - gak quzier ambak fathil
2002 busan mikaela marã­a jaworski lee jin - kyung tadayoshi hayashi
2006 doha ali yousuf al - rumaihi jasmine chen - shao man joo jung - hyun
2010 guangzhou ramzy al duhami latifa al maktom khaled al - eid

Step 2: Extract the distinct values from the 'location' column then add column 'distinct_location' to existing table.

SQL command for the step:

ALTER TABLE table_sql ADD COLUMN distinct_location VARCHAR; UPDATE table_sql SET distinct_location = (SELECT DISTINCT location FROM table_sql);
year location gold silver bronze
1982 new delhi nadia al - moutawaa jamila al - moutawaa bariaa salem al - sabbah
1986 seoul takashi tomura shuichi toki ryuzo okuno
2002 busan mikaela marã­a jaworski lee jin - kyung tadayoshi hayashi
2006 doha ali yousuf al - rumaihi jasmine chen - shao man joo jung - hyun
2010 guangzhou ramzy al duhami latifa al maktom khaled al - eid

Step 3: Select rows where 'distinct_location' is greater than 1.

SQL command for the step:

SELECT * FROM table_sql WHERE distinct_location > 1;
location distinct_location
new delhi 5
seoul 5
busan 5
doha 5
guangzhou 5

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

SQL command for the step:

SELECT CASE WHEN COUNT(*) = 0 THEN TRUE ELSE FALSE END AS verification FROM table_sql;
location distinct_location
new delhi 5
seoul 5
busan 5
doha 5
guangzhou 5

Verification:

The statement is FALSE