Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: Find the average access counts of documents with functional area "Acknowledgement". [/INST]

Output: SELECT avg(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code  =  t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code  =  t3.functional_area_code WHERE t3.functional_area_description  =  "Acknowledgement";


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What are the average access counts of documents that have the functional area description "Acknowledgement"? [/INST]

Output: SELECT avg(t1.access_count) FROM documents AS t1 JOIN document_functional_areas AS t2 ON t1.document_code  =  t2.document_code JOIN functional_areas AS t3 ON t2.functional_area_code  =  t3.functional_area_code WHERE t3.functional_area_description  =  "Acknowledgement";


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: Find names of the document without any images. [/INST]

Output: SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code JOIN document_sections_images AS t3 ON t2.section_id  =  t3.section_id;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What are the names of documents that do not have any images? [/INST]

Output: SELECT document_name FROM documents EXCEPT SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code JOIN document_sections_images AS t3 ON t2.section_id  =  t3.section_id;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What is the name of the document with the most number of sections? [/INST]

Output: SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code GROUP BY t1.document_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: Return the name of the document that has the most sections. [/INST]

Output: SELECT t1.document_name FROM documents AS t1 JOIN document_sections AS t2 ON t1.document_code  =  t2.document_code GROUP BY t1.document_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: List all the document names which contains "CV". [/INST]

Output: SELECT document_name FROM documents WHERE document_name LIKE "%CV%";


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What are the names of documents that contain the substring "CV"? [/INST]

Output: SELECT document_name FROM documents WHERE document_name LIKE "%CV%";


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: How many users are logged in? [/INST]

Output: SELECT count(*) FROM users WHERE user_login  =  1;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: Count the number of users that are logged in. [/INST]

Output: SELECT count(*) FROM users WHERE user_login  =  1;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: Find the description of the most popular role among the users that have logged in. [/INST]

Output: SELECT role_description FROM ROLES WHERE role_code  =  (SELECT role_code FROM users WHERE user_login  =  1 GROUP BY role_code ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What is the description of the most popular role among users that have logged in? [/INST]

Output: SELECT role_description FROM ROLES WHERE role_code  =  (SELECT role_code FROM users WHERE user_login  =  1 GROUP BY role_code ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: Find the average access count of documents with the least popular structure. [/INST]

Output: SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What is the average access count of documents that have the least common structure? [/INST]

Output: SELECT avg(access_count) FROM documents GROUP BY document_structure_code ORDER BY count(*) ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: List all the image name and URLs in the order of their names. [/INST]

Output: SELECT image_name ,  image_url FROM images ORDER BY image_name;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What are the names and urls of images, sorted alphabetically? [/INST]

Output: SELECT image_name ,  image_url FROM images ORDER BY image_name;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: Find the number of users in each role. [/INST]

Output: SELECT count(*) ,  role_code FROM users GROUP BY role_code;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What are the different role codes for users, and how many users have each? [/INST]

Output: SELECT count(*) ,  role_code FROM users GROUP BY role_code;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: What document types have more than 2 corresponding documents? [/INST]

Output: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*)  >  2;


Input:
[INST] Here is a database schema:
Roles :
role_code [ TEXT ] primary_key
role_description [ TEXT ]

Users :
user_id [ INT ] primary_key
role_code [ TEXT ] Users.role_code = Roles.role_code
user_name [ TEXT ]
user_login [ TEXT ]
password [ TEXT ]

Document_Structures :
document_structure_code [ TEXT ] primary_key
parent_document_structure_code [ TEXT ]
document_structure_description [ TEXT ]

Functional_Areas :
functional_area_code [ TEXT ] primary_key
parent_functional_area_code [ TEXT ]
functional_area_description [ TEXT ]

Images :
image_id [ INT ] primary_key
image_alt_text [ TEXT ]
image_name [ TEXT ]
image_url [ TEXT ]

Documents :
document_code [ TEXT ] primary_key
document_structure_code [ TEXT ] Documents.document_structure_code = Document_Structures.document_structure_code
document_type_code [ TEXT ]
access_count [ INT ]
document_name [ TEXT ]

Document_Functional_Areas :
document_code [ TEXT ] Document_Functional_Areas.document_code = Documents.document_code
functional_area_code [ TEXT ] Document_Functional_Areas.functional_area_code = Functional_Areas.functional_area_code

Document_Sections :
section_id [ INT ] primary_key
document_code [ TEXT ] Document_Sections.document_code = Documents.document_code
section_sequence [ INT ]
section_code [ TEXT ]
section_title [ TEXT ]

Document_Sections_Images :
section_id [ INT ] primary_key Document_Sections_Images.section_id = Document_Sections.section_id
image_id [ INT ] Document_Sections_Images.image_id = Images.image_id

Please write me a SQL statement that answers the following question: Give the codes of document types that have more than 2 corresponding documents. [/INST]

Output: SELECT document_type_code FROM documents GROUP BY document_type_code HAVING count(*)  >  2;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: How many companies are there? [/INST]

Output: SELECT count(*) FROM Companies;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Count the number of companies. [/INST]

Output: SELECT count(*) FROM Companies;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: List the names of companies in descending order of market value. [/INST]

Output: SELECT name FROM Companies ORDER BY Market_Value_billion DESC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Sort the company names in descending order of the company's market value. [/INST]

Output: SELECT name FROM Companies ORDER BY Market_Value_billion DESC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: What are the names of companies whose headquarters are not "USA"? [/INST]

Output: SELECT name FROM Companies WHERE Headquarters != 'USA';


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Find the names of the companies whose headquarters are not located in "USA". [/INST]

Output: SELECT name FROM Companies WHERE Headquarters != 'USA';


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: What are the name and assets of each company, sorted in ascending order of company name? [/INST]

Output: SELECT name ,  Assets_billion FROM Companies ORDER BY name ASC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: List the name and assets of each company in ascending order of company name. [/INST]

Output: SELECT name ,  Assets_billion FROM Companies ORDER BY name ASC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: What are the average profits of companies? [/INST]

Output: SELECT avg(Profits_billion) FROM Companies;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Compute the average profits companies make. [/INST]

Output: SELECT avg(Profits_billion) FROM Companies;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: What are the maximum and minimum sales of the companies whose industries are not "Banking". [/INST]

Output: SELECT max(Sales_billion) ,  min(Sales_billion) FROM Companies WHERE Industry != "Banking";


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Find the maximum and minimum sales of the companies that are not in the "Banking" industry. [/INST]

Output: SELECT max(Sales_billion) ,  min(Sales_billion) FROM Companies WHERE Industry != "Banking";


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: How many different industries are the companies in? [/INST]

Output: SELECT count(DISTINCT Industry) FROM Companies;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Count the number of distinct company industries. [/INST]

Output: SELECT count(DISTINCT Industry) FROM Companies;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: List the names of buildings in descending order of building height. [/INST]

Output: SELECT name FROM buildings ORDER BY Height DESC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: What are the names of buildings sorted in descending order of building height? [/INST]

Output: SELECT name FROM buildings ORDER BY Height DESC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Find the stories of the building with the largest height. [/INST]

Output: SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: What is the stories of highest building? [/INST]

Output: SELECT Stories FROM buildings ORDER BY Height DESC LIMIT 1;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: List the name of a building along with the name of a company whose office is in the building. [/INST]

Output: SELECT T3.name ,  T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id  =  T2.id JOIN Companies AS T3 ON T1.company_id  =  T3.id;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: For each company, return the company name and the name of the building its office is located in. [/INST]

Output: SELECT T3.name ,  T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id  =  T2.id JOIN Companies AS T3 ON T1.company_id  =  T3.id;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Show the names of the buildings that have more than one company offices. [/INST]

Output: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id  =  T2.id JOIN Companies AS T3 ON T1.company_id  =  T3.id GROUP BY T1.building_id HAVING COUNT(*)  >  1;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Which buildings have more than one company offices? Give me the building names. [/INST]

Output: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id  =  T2.id JOIN Companies AS T3 ON T1.company_id  =  T3.id GROUP BY T1.building_id HAVING COUNT(*)  >  1;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Show the name of the building that has the most company offices. [/INST]

Output: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id  =  T2.id JOIN Companies AS T3 ON T1.company_id  =  T3.id GROUP BY T1.building_id ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Which building has the largest number of company offices? Give me the building name. [/INST]

Output: SELECT T2.name FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id  =  T2.id JOIN Companies AS T3 ON T1.company_id  =  T3.id GROUP BY T1.building_id ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Please show the names of the buildings whose status is "on-hold", in ascending order of stories. [/INST]

Output: SELECT name FROM buildings WHERE Status  =  "on-hold" ORDER BY Stories ASC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Find the names of the buildings in "on-hold" status, and sort them in ascending order of building stories. [/INST]

Output: SELECT name FROM buildings WHERE Status  =  "on-hold" ORDER BY Stories ASC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Please show each industry and the corresponding number of companies in that industry. [/INST]

Output: SELECT Industry ,  COUNT(*) FROM Companies GROUP BY Industry;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Whah are the name of each industry and the number of companies in that industry? [/INST]

Output: SELECT Industry ,  COUNT(*) FROM Companies GROUP BY Industry;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Please show the industries of companies in descending order of the number of companies. [/INST]

Output: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Sort all the industries in descending order of the count of companies in each industry [/INST]

Output: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: List the industry shared by the most companies. [/INST]

Output: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Which industry has the most companies? [/INST]

Output: SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: List the names of buildings that have no company office. [/INST]

Output: SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations);


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Which buildings do not have any company office? Give me the building names. [/INST]

Output: SELECT name FROM buildings WHERE id NOT IN (SELECT building_id FROM Office_locations);


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Show the industries shared by companies whose headquarters are "USA" and companies whose headquarters are "China". [/INST]

Output: SELECT Industry FROM Companies WHERE Headquarters  =  "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters  =  "China";


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Which industries have both companies with headquarter in "USA" and companies with headquarter in "China"? [/INST]

Output: SELECT Industry FROM Companies WHERE Headquarters  =  "USA" INTERSECT SELECT Industry FROM Companies WHERE Headquarters  =  "China";


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Find the number of companies whose industry is "Banking" or "Conglomerate", [/INST]

Output: SELECT count(*) FROM Companies WHERE Industry  =  "Banking" OR Industry  =  "Conglomerate";


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: How many companies are in either "Banking" industry or "Conglomerate" industry? [/INST]

Output: SELECT count(*) FROM Companies WHERE Industry  =  "Banking" OR Industry  =  "Conglomerate";


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Show the headquarters shared by more than two companies. [/INST]

Output: SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*)  >  2;


Input:
[INST] Here is a database schema:
buildings :
id [ INT ] primary_key
name [ TEXT ]
City [ TEXT ]
Height [ INT ]
Stories [ INT ]
Status [ TEXT ]

Companies :
id [ INT ] primary_key
name [ TEXT ]
Headquarters [ TEXT ]
Industry [ TEXT ]
Sales_billion [ INT ]
Profits_billion [ INT ]
Assets_billion [ INT ]
Market_Value_billion [ TEXT ]

Office_locations :
building_id [ INT ] primary_key Office_locations.building_id = buildings.id
company_id [ INT ] Office_locations.company_id = Companies.id
move_in_year [ INT ]

Please write me a SQL statement that answers the following question: Which headquarter locations are used by more than 2 companies? [/INST]

Output: SELECT Headquarters FROM Companies GROUP BY Headquarters HAVING COUNT(*)  >  2;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: How many products are there? [/INST]

Output: SELECT count(*) FROM Products;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: List the name of products in ascending order of price. [/INST]

Output: SELECT Product_Name FROM Products ORDER BY Product_Price ASC;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: What are the names and type codes of products? [/INST]

Output: SELECT Product_Name ,  Product_Type_Code FROM Products;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show the prices of the products named "Dining" or "Trading Policy". [/INST]

Output: SELECT Product_Price FROM Products WHERE Product_Name  =  "Dining" OR Product_Name  =  "Trading Policy";


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: What is the average price for products? [/INST]

Output: SELECT avg(Product_Price) FROM Products;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: What is the name of the product with the highest price? [/INST]

Output: SELECT Product_Name FROM Products ORDER BY Product_Price DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show different type codes of products and the number of products with each type code. [/INST]

Output: SELECT Product_Type_Code ,  COUNT(*) FROM Products GROUP BY Product_Type_Code;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show the most common type code across products. [/INST]

Output: SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show the product type codes that have at least two products. [/INST]

Output: SELECT Product_Type_Code FROM Products GROUP BY Product_Type_Code HAVING COUNT(*)  >=  2;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show the product type codes that have both products with price higher than 4500 and products with price lower than 3000. [/INST]

Output: SELECT Product_Type_Code FROM Products WHERE Product_Price  >  4500 INTERSECT SELECT Product_Type_Code FROM Products WHERE Product_Price  <  3000;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show the names of products and the number of events they are in. [/INST]

Output: SELECT T1.Product_Name ,  COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID  =  T2.Product_ID GROUP BY T1.Product_Name;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show the names of products and the number of events they are in, sorted by the number of events in descending order. [/INST]

Output: SELECT T1.Product_Name ,  COUNT(*) FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID  =  T2.Product_ID GROUP BY T1.Product_Name ORDER BY COUNT(*) DESC;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show the names of products that are in at least two events. [/INST]

Output: SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID  =  T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*)  >=  2;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: Show the names of products that are in at least two events in ascending alphabetical order of product name. [/INST]

Output: SELECT T1.Product_Name FROM Products AS T1 JOIN Products_in_Events AS T2 ON T1.Product_ID  =  T2.Product_ID GROUP BY T1.Product_Name HAVING COUNT(*)  >=  2 ORDER BY T1.Product_Name;


Input:
[INST] Here is a database schema:
Addresses :
Address_ID [ INT ] primary_key
address_details [ TEXT ]

Locations :
Location_ID [ INT ] primary_key
Other_Details [ TEXT ]

Products :
Product_ID [ INT ] primary_key
Product_Type_Code [ TEXT ]
Product_Name [ TEXT ]
Product_Price [ INT ]

Parties :
Party_ID [ INT ] primary_key
Party_Details [ TEXT ]

Assets :
Asset_ID [ INT ] primary_key
Other_Details [ TEXT ]

Channels :
Channel_ID [ INT ] primary_key
Other_Details [ TEXT ]

Finances :
Finance_ID [ INT ] primary_key
Other_Details [ TEXT ]

Events :
Event_ID [ INT ] primary_key
Address_ID [ INT ] Events.Address_ID = Addresses.Address_ID
Channel_ID [ INT ]
Event_Type_Code [ TEXT ]
Finance_ID [ INT ] Events.Finance_ID = Finances.Finance_ID
Location_ID [ INT ] Events.Location_ID = Locations.Location_ID

Products_in_Events :
Product_in_Event_ID [ INT ] primary_key
Event_ID [ INT ] Products_in_Events.Event_ID = Events.Event_ID
Product_ID [ INT ] Products_in_Events.Product_ID = Products.Product_ID

Parties_in_Events :
Party_ID [ INT ] primary_key Parties_in_Events.Party_ID = Parties.Party_ID
Event_ID [ INT ] Parties_in_Events.Event_ID = Events.Event_ID
Role_Code [ TEXT ]

Agreements :
Document_ID [ INT ] primary_key
Event_ID [ INT ] Agreements.Event_ID = Events.Event_ID

Assets_in_Events :
Asset_ID [ INT ] primary_key
Event_ID [ INT ] Assets_in_Events.Event_ID = Events.Event_ID

Please write me a SQL statement that answers the following question: List the names of products that are not in any event. [/INST]

Output: SELECT Product_Name FROM Products WHERE Product_ID NOT IN (SELECT Product_ID FROM Products_in_Events);


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: How many artworks are there? [/INST]

Output: SELECT count(*) FROM artwork;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: List the name of artworks in ascending alphabetical order. [/INST]

Output: SELECT Name FROM artwork ORDER BY Name ASC;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: List the name of artworks whose type is not "Program Talent Show". [/INST]

Output: SELECT Name FROM artwork WHERE TYPE != "Program Talent Show";


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names and locations of festivals? [/INST]

Output: SELECT Festival_Name ,  LOCATION FROM festival_detail;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of the chairs of festivals, sorted in ascending order of the year held? [/INST]

Output: SELECT Chair_Name FROM festival_detail ORDER BY YEAR ASC;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: What is the location of the festival with the largest number of audience? [/INST]

Output: SELECT LOCATION FROM festival_detail ORDER BY Num_of_Audience DESC LIMIT 1;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of festivals held in year 2007? [/INST]

Output: SELECT Festival_Name FROM festival_detail WHERE YEAR  =  2007;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: What is the average number of audience for festivals? [/INST]

Output: SELECT avg(Num_of_Audience) FROM festival_detail;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of the three most recent festivals. [/INST]

Output: SELECT Festival_Name FROM festival_detail ORDER BY YEAR DESC LIMIT 3;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: For each nomination, show the name of the artwork and name of the festival where it is nominated. [/INST]

Output: SELECT T2.Name ,  T3.Festival_Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID  =  T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID  =  T3.Festival_ID;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: Show distinct types of artworks that are nominated in festivals in 2007. [/INST]

Output: SELECT DISTINCT T2.Type FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID  =  T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID  =  T3.Festival_ID WHERE T3.Year  =  2007;


Input:
[INST] Here is a database schema:
festival_detail :
Festival_ID [ INT ] primary_key
Festival_Name [ TEXT ]
Chair_Name [ TEXT ]
Location [ TEXT ]
Year [ INT ]
Num_of_Audience [ INT ]

artwork :
Artwork_ID [ INT ] primary_key
Type [ TEXT ]
Name [ TEXT ]

nomination :
Artwork_ID [ INT ] primary_key nomination.Artwork_ID = artwork.Artwork_ID
Festival_ID [ INT ] nomination.Festival_ID = festival_detail.Festival_ID
Result [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of artworks in ascending order of the year they are nominated in. [/INST]

Output: SELECT T2.Name FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID  =  T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID  =  T3.Festival_ID ORDER BY T3.Year;