sharkiefff/RBAC-Text2SQL-Benchmark huggingface dataset:
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: Return the id of the project that has the fewest corresponding documents.
Answer: SELECT project_id FROM Documents GROUP BY project_id ORDER BY count(*) ASC LIMIT 1
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT project_id FROM Documents GROUP BY project_id ORDER BY count(*) ASC LIMIT 1
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: Show the ids for projects with at least 2 documents.
Answer: SELECT project_id FROM Documents GROUP BY project_id HAVING count(*)  >=  2
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT project_id FROM Documents GROUP BY project_id HAVING count(*)  >=  2
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: What are project ids of projects that have 2 or more corresponding documents?
Answer: SELECT project_id FROM Documents GROUP BY project_id HAVING count(*)  >=  2
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT project_id FROM Documents GROUP BY project_id HAVING count(*)  >=  2
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: List document type codes and the number of documents in each code.
Answer: SELECT document_type_code ,  count(*) FROM Documents GROUP BY document_type_code
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT document_type_code ,  count(*) FROM Documents GROUP BY document_type_code
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: How many documents are there of each type?
Answer: SELECT document_type_code ,  count(*) FROM Documents GROUP BY document_type_code
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT document_type_code ,  count(*) FROM Documents GROUP BY document_type_code
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: What is the document type code with most number of documents?
Answer: SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: Return the code of the document type that is most common.
Answer: SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT document_type_code FROM Documents GROUP BY document_type_code ORDER BY count(*) DESC LIMIT 1
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: Show the document type code with fewer than 3 documents.
Answer: SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*)  <  3
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*)  <  3
##Instruction:
Database: cre_Docs_and_Epenses
Total Tables: 7
Total Columns: 22

Table Schemas:

cre_Docs_and_Epenses contains tables such as Ref_Document_Types, Ref_Budget_Codes, Projects, Documents, Statements, Documents_with_Expenses, Accounts.
Table Ref_Document_Types has columns such as Document_Type_Code, Document_Type_Name, Document_Type_Description.
Document_Type_Code is the primary key.
Table Ref_Budget_Codes has columns such as Budget_Type_Code, Budget_Type_Description.
Budget_Type_Code is the primary key.
Table Projects has columns such as Project_ID, Project_Details.
Project_ID is the primary key.
Table Documents has columns such as Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details.
Document_ID is the primary key.
Table Statements has columns such as Statement_ID, Statement_Details.
Statement_ID is the primary key.
Table Documents_with_Expenses has columns such as Document_ID, Budget_Type_Code, Document_Details.
Document_ID is the primary key.
Table Accounts has columns such as Account_ID, Statement_ID, Account_Details.
Account_ID is the primary key.
The Project_ID of Documents is the foreign key of Project_ID of Projects.
The Document_Type_Code of Documents is the foreign key of Document_Type_Code of Ref_Document_Types.
The Statement_ID of Statements is the foreign key of Document_ID of Documents.
The Document_ID of Documents_with_Expenses is the foreign key of Document_ID of Documents.
The Budget_Type_Code of Documents_with_Expenses is the foreign key of Budget_Type_Code of Ref_Budget_Codes.
The Statement_ID of Accounts is the foreign key of Statement_ID of Statements.

##Role Access Policy (Column-Level):
Role: DocumentManager
Accessible Columns: Ref_Document_Types: ALL COLUMNS; Projects: Project_ID, Project_Details; Documents: Document_ID, Document_Type_Code, Project_ID, Document_Date, Document_Name, Document_Description, Other_Details

Based on the above schema and your role's column-level access policy, generate a SQL query to answer the question. If your role does not have access to the required columns, respond with: "Sorry, I cannot answer."


Question: What are the codes corresponding to document types for which there are less than 3 documents?
Answer: SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*)  <  3
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT document_type_code FROM Documents GROUP BY document_type_code HAVING count(*)  <  3