Task: NL2SQL (source dataset: KaggleDBQA)

Natural language to SQL, also known as NL2SQL, is the problem of generating a SQL query that can be executed on a input table, for a given natural language question.

You will be given an input table called "table" in the markdown format, as well as a question. Your task is to generate an SQL query that can be executed on the input table to answer the question.

Please ensure that the generated SQL only return relevant columns being specifically asked in the question (e.g., in SQL please don't return more than one columns in SELECT if only one column is needed to answer the given question, and similarly please refrain from using SELECT * unless the entire row is needed to answer the question).
 
When generating SQL code, please use the SQLite syntax to ensure that your SQL is executable on SQLite3. Use only columns that are present in the table, always use quotes around your column and table names (some column names have punctuation or special characters), and refer to the columns using the column-names exactly as they appear in the table, do not add or remove punctuation (underscore, slash, etc.)

No explanation, return the code only with the following markdown codeblock format : ```sql<SQL CODE>```. For example, ```sql
SELECT * FROM "table"
``` is a valid format.

Database:
StudentMathScore

Tables:

Table: FINREV_FED_17
|   state_code |       idcensus | school_district                          |   nces_id |   yr_data |   t_fed_rev |    c14 |    c25 |
|-------------:|---------------:|:-----------------------------------------|----------:|----------:|------------:|-------:|-------:|
|           33 | 33203100130100 | NEW YORK CITY SCHOOL DISTRICT            |   3620580 |        17 |     2061297 | 956851 | 439209 |
|            5 |  5501905900000 | LOS ANGELES UNIF SCH DIST                |    622710 |        17 |     1146298 | 376182 | 390711 |
|           14 | 14501615800000 | CITY OF CHICAGO SCHOOL DISTRICT 299      |   1709930 |        17 |      783943 | 290912 | 200517 |
|           10 | 10501300100000 | MIAMI-DADE COUNTY PUBLIC SCHOOL DISTRICT |   1200390 |        17 |      451479 | 139461 | 138098 |
|           39 | 39505100100000 | PHILADELPHIA SCHOOL DISTRICT             |   4218990 |        17 |      321363 | 140449 |  80566 |
|           29 | 29500200100000 | CLARK COUNTY SCHOOL DISTRICT             |   3200060 |        17 |      309987 |  97919 | 113637 |
|           10 | 10502900100000 | HILLSBOROUGH COUNTY SCHOOL DISTRICT      |   1200870 |        17 |      302331 |  68690 |  86051 |
|           44 | 44510101100000 | HOUSTON IND SCH DIST 912                 |   4823640 |        17 |      298648 |  91977 | 113619 |
|           10 | 10500600100000 | BROWARD COUNTY SCHOOL DISTRICT           |   1200180 |        17 |      295473 |  67179 |  85690 |
|           44 | 44505700500000 | DALLAS IND SCH DISTRICT 905              |   4816230 |        17 |      282730 |  74407 | 105876 |


Table: NDECoreExcel_Math_Grade8
|   year | state                | all_students   |   average_scale_score |
|-------:|:---------------------|:---------------|----------------------:|
|   2017 | National             | All students   |                   283 |
|   2017 | Alabama              | All students   |                   268 |
|   2017 | Alaska               | All students   |                   277 |
|   2017 | Arizona              | All students   |                   282 |
|   2017 | Arkansas             | All students   |                   274 |
|   2017 | California           | All students   |                   277 |
|   2017 | Colorado             | All students   |                   286 |
|   2017 | Connecticut          | All students   |                   284 |
|   2017 | Delaware             | All students   |                   278 |
|   2017 | District of Columbia | All students   |                   266 |


Table: FINREV_FED_KEY_17
|   State_Code | State                | #_Records   |
|-------------:|:---------------------|:------------|
|            1 | Alabama              | 137         |
|            2 | Alaska               | 54          |
|            3 | Arizona              | 235         |
|            4 | Arkansas             | 250         |
|            5 | California           | 1,046       |
|            6 | Colorado             | 197         |
|            7 | Connecticut          | 174         |
|            8 | Delaware             | 19          |
|            9 | District of Columbia | 1           |
|           10 | Florida              | 67          |


Question: Which state spent the least revenue towards schools and whats the state average score

db_id: StudentMathScore
tables: name: FINREV_FED_17
data: FINREV_FED_17.csv
name: NDECoreExcel_Math_Grade8
data: NDECoreExcel_Math_Grade8.csv
name: FINREV_FED_KEY_17
data: FINREV_FED_KEY_17.csv
label: SELECT T2.state, T3.average_scale_score FROM FINREV_FED_KEY_17 as T2 JOIN FINREV_FED_17 as T1 ON T1.state_code = T2.state_code JOIN NDECoreExcel_Math_Grade8 as T3 ON T2.state = T3.state GROUP BY T2.state ORDER BY sum(T1.t_fed_rev) LIMIT 1
sqlite_path: $MMTU_HOME/data_sqlite/KaggleDBQA/databases/StudentMathScore/StudentMathScore.sqlite