Task: NL2SQL (source dataset: Spider)

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:
cre_Students_Information_Systems

Tables:

Table: Students
|   student_id | bio_data   | student_details   |
|-------------:|:-----------|:------------------|
|          276 | Camila     | Suite 076         |
|          287 | Dino       | Suite 970         |
|          325 | Pansy      | Apt. 149          |
|          361 | Louvenia   | Suite 218         |
|          415 | Leora      | Apt. 748          |
|          435 | Vanessa    | Suite 684         |
|          471 | Antone     | Suite 303         |
|          567 | Arturo     | Apt. 491          |
|          648 | Leonard    | Suite 505         |
|          669 | Brenden    | Apt. 305          |


Table: Transcripts
|   transcript_id |   student_id | date_of_transcript      | transcript_details   |
|----------------:|-------------:|:------------------------|:---------------------|
|             131 |          669 | 1973-08-09 00:00:00.000 | Good                 |
|             138 |          824 | 1973-11-05 00:00:00.000 | Good                 |
|             145 |          361 | 2002-11-23 00:00:00.000 | Good                 |
|             167 |          276 | 2017-03-17 00:00:00.000 | Pass                 |
|             177 |          811 | 2010-12-14 00:00:00.000 | Good                 |
|             224 |          567 | 1973-05-05 00:00:00.000 | Pass                 |
|             264 |          824 | 2005-06-04 00:00:00.000 | Good                 |
|             276 |          415 | 2002-02-26 00:00:00.000 | Pass                 |
|             283 |          287 | 1979-04-05 00:00:00.000 | Good                 |
|             293 |          276 | 2017-10-31 00:00:00.000 | Pass                 |


Table: Behaviour_Monitoring
|   behaviour_monitoring_id |   student_id | behaviour_monitoring_details   |
|--------------------------:|-------------:|:-------------------------------|
|                       142 |          435 | A                              |
|                       220 |          811 | A                              |
|                       248 |          567 | A                              |
|                       265 |          984 | B                              |
|                       376 |          648 | B                              |
|                       434 |          777 | B                              |
|                       448 |          567 | C                              |
|                       477 |          287 | C                              |
|                       572 |          287 | A                              |
|                       674 |          361 | C                              |


Table: Addresses
|   address_id | address_details                  |
|-------------:|:---------------------------------|
|            0 | 607 Nikita Cape Suite 449        |
|            4 | 4474 Dina Park                   |
|            5 | 19571 Garrett Manor              |
|           34 | 423 Rosenbaum Shores Apt. 812    |
|           47 | 100 Hayes Point                  |
|           51 | 0773 Kaci Villages               |
|           66 | 33376 Terry Mews Suite 922       |
|           72 | 90147 Greenholt Springs Apt. 497 |
|           74 | 1951 Beatty Oval                 |
|           76 | 41082 Calista Mountains          |


Table: Ref_Event_Types
| event_type_code   | event_type_description   |
|:------------------|:-------------------------|
| Exam              | Exam                     |
| Registration      | Registration             |


Table: Ref_Achievement_Type
| achievement_type_code   | achievement_type_description   |
|:------------------------|:-------------------------------|
| Athletic                | Athletic                       |
| Scholastic              | Scholastic                     |


Table: Ref_Address_Types
| address_type_code   | address_type_description   |
|:--------------------|:---------------------------|
| CO                  | College                    |
| HM                  | Home                       |


Table: Ref_Detention_Type
| detention_type_code   | detention_type_description   |
|:----------------------|:-----------------------------|
| After School          | After School                 |
| Break                 | On break                     |
| Illness               | Leave for illness            |
| Lunch                 | During lunchtime             |


Table: Student_Events
|   event_id | event_type_code   |   student_id | event_date              | other_details   |
|-----------:|:------------------|-------------:|:------------------------|:----------------|
|        146 | Exam              |          287 | 2008-08-15 22:16:17.000 |                 |
|        161 | Exam              |          777 | 2014-07-15 18:18:15.000 |                 |
|        189 | Exam              |          361 | 2013-04-14 04:14:10.000 |                 |
|        227 | Registration      |          669 | 2012-12-06 06:44:53.000 |                 |


Table: Teachers
|   teacher_id | teacher_details   |
|-------------:|:------------------|
|          115 | Jon               |
|          127 | Tyson             |
|          164 | Trinity           |
|          172 | Viva              |
|          195 | Osvaldo           |
|          212 | Isabel            |
|          226 | Adella            |
|          234 | Chasity           |
|          252 | Wilfredo          |
|          253 | Marielle          |


Table: Student_Loans
|   student_loan_id |   student_id | date_of_loan            |   amount_of_loan | other_details   |
|------------------:|-------------:|:------------------------|-----------------:|:----------------|
|               165 |          777 | 1980-01-06 00:00:00.000 |          2216.15 |                 |
|               169 |          669 | 1991-03-24 00:00:00.000 |          5223.18 |                 |
|               188 |          777 | 1983-08-01 00:00:00.000 |          3221.49 |                 |
|               205 |          777 | 1977-08-27 00:00:00.000 |          3358.87 |                 |
|               267 |          435 | 2018-01-17 00:00:00.000 |          5174.76 |                 |
|               269 |          361 | 1989-05-07 00:00:00.000 |          3803.6  |                 |
|               287 |          984 | 1989-04-23 00:00:00.000 |          1561.57 |                 |
|               366 |          361 | 1992-11-14 00:00:00.000 |          4190.32 |                 |
|               408 |          762 | 1994-02-24 00:00:00.000 |          4213.13 |                 |
|               550 |          762 | 2004-04-11 00:00:00.000 |          1644.65 |                 |


Table: Classes
|   class_id |   student_id |   teacher_id | class_details        |
|-----------:|-------------:|-------------:|:---------------------|
|        114 |          435 |          253 | databases            |
|        195 |          471 |          274 | english              |
|        235 |          811 |          282 | writing              |
|        248 |          471 |          252 | statistics           |
|        294 |          762 |          234 | math 100             |
|        354 |          287 |          302 | math 300             |
|        387 |          325 |          316 | statistics 100       |
|        411 |          811 |          316 | databases 200        |
|        424 |          669 |          252 | computer science 100 |
|        429 |          669 |          195 | data structure       |


Table: Students_Addresses
|   student_address_id |   address_id | address_type_code   |   student_id | date_from               | date_to                 |
|---------------------:|-------------:|:--------------------|-------------:|:------------------------|:------------------------|
|                   11 |           94 | HM                  |          984 | 2011-06-29 09:45:39.000 | 2018-03-22 07:50:48.000 |
|                   15 |           76 | HM                  |          415 | 2011-10-04 09:58:41.000 | 2018-03-14 18:32:37.000 |
|                   20 |           97 | CO                  |          777 | 2015-02-01 00:20:42.000 | 2018-03-04 09:58:38.000 |
|                   23 |           72 | CO                  |          361 | 2015-03-14 15:55:46.000 | 2018-03-08 08:41:07.000 |
|                   33 |           97 | HM                  |          762 | 2017-05-18 23:15:01.000 | 2018-03-20 08:06:53.000 |
|                   35 |           98 | HM                  |          762 | 2009-04-27 17:42:38.000 | 2018-02-28 07:36:43.000 |
|                   45 |           90 | HM                  |          777 | 2014-03-28 08:03:34.000 | 2018-03-11 19:21:54.000 |
|                   56 |           94 | HM                  |          777 | 2009-08-24 22:57:30.000 | 2018-03-10 09:05:12.000 |
|                   59 |           98 | HM                  |          777 | 2013-05-27 16:51:49.000 | 2018-02-27 11:03:50.000 |
|                   67 |            0 | HM                  |          361 | 2011-04-29 03:20:26.000 | 2018-03-02 04:33:35.000 |


Table: Detention
|   detention_id | detention_type_code   |   student_id | datetime_detention_start   | datetime_detention_end   | detention_summary   | other_details   |
|---------------:|:----------------------|-------------:|:---------------------------|:-------------------------|:--------------------|:----------------|
|            133 | Lunch                 |          361 | 2012-03-18 09:49:33.000    | 2011-09-15 05:58:59.000  |                     |                 |
|            141 | After School          |          811 | 2012-06-07 15:01:05.000    | 2009-05-23 17:33:31.000  |                     |                 |
|            211 | Break                 |          762 | 2011-04-24 17:23:32.000    | 2013-09-06 15:49:53.000  |                     |                 |
|            242 | After School          |          648 | 2014-01-16 00:49:33.000    | 2013-04-07 15:42:52.000  |                     |                 |
|            384 | Illness               |          762 | 2016-12-28 21:44:59.000    | 2013-04-20 13:13:40.000  |                     |                 |
|            401 | Break                 |          415 | 2011-03-22 20:51:56.000    | 2013-10-06 03:49:35.000  |                     |                 |
|            451 | After School          |          361 | 2014-02-03 00:18:05.000    | 2012-05-09 00:54:20.000  |                     |                 |
|            478 | Illness               |          762 | 2010-03-14 06:33:25.000    | 2015-10-16 19:21:09.000  |                     |                 |
|            492 | Break                 |          471 | 2018-03-16 04:10:29.000    | 2008-06-03 01:53:37.000  |                     |                 |
|            545 | Illness               |          276 | 2013-06-24 06:36:47.000    | 2014-05-18 21:10:48.000  |                     |                 |


Table: Achievements
|   achievement_id | achievement_type_code   |   student_id |   date_achievement | achievement_details   | other_details   |
|-----------------:|:------------------------|-------------:|-------------------:|:----------------------|:----------------|
|              153 | Athletic                |          777 |               2013 | Gold                  |                 |
|              159 | Athletic                |          415 |               2013 | Gold                  |                 |
|              262 | Scholastic              |          415 |               2014 | Gold                  |                 |
|              264 | Scholastic              |          471 |               2014 | Silver                |                 |
|              316 | Scholastic              |          648 |               2014 | Gold                  |                 |
|              340 | Scholastic              |          276 |               2014 | Bronze                |                 |
|              450 | Athletic                |          669 |               2014 | Bronze                |                 |
|              602 | Scholastic              |          824 |               2014 | Silver                |                 |
|              650 | Athletic                |          777 |               2014 | Silver                |                 |
|              672 | Athletic                |          984 |               2014 | Gold                  |                 |


Question: What is the average amount of a student loan?

db_id: cre_Students_Information_Systems
tables: name: Students
data: Students.csv
name: Transcripts
data: Transcripts.csv
name: Behaviour_Monitoring
data: Behaviour_Monitoring.csv
name: Addresses
data: Addresses.csv
name: Ref_Event_Types
data: Ref_Event_Types.csv
name: Ref_Achievement_Type
data: Ref_Achievement_Type.csv
name: Ref_Address_Types
data: Ref_Address_Types.csv
name: Ref_Detention_Type
data: Ref_Detention_Type.csv
name: Student_Events
data: Student_Events.csv
name: Teachers
data: Teachers.csv
name: Student_Loans
data: Student_Loans.csv
name: Classes
data: Classes.csv
name: Students_Addresses
data: Students_Addresses.csv
name: Detention
data: Detention.csv
name: Achievements
data: Achievements.csv
label: SELECT avg(amount_of_loan) FROM Student_Loans
sqlite_path: $MMTU_HOME/data_sqlite/spider/spider_data/test_database/cre_Students_Information_Systems/cre_Students_Information_Systems.sqlite