sharkiefff/RBAC-Text2SQL-Benchmark huggingface dataset:
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
ratio of customers who pay in EUR against customers who pay in CZK = count(Currency = 'EUR') / count(Currency = 'CZK').

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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 ratio of customers who pay in EUR against customers who pay in CZK?
Evidence: ratio of customers who pay in EUR against customers who pay in CZK = count(Currency = 'EUR') / count(Currency = 'CZK').
Answer: SELECT CAST(SUM(IIF(Currency = 'EUR', 1, 0)) AS FLOAT) / SUM(IIF(Currency = 'CZK', 1, 0)) AS ratio FROM customers
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT CAST(SUM(IIF(Currency = 'EUR', 1, 0)) AS FLOAT) / SUM(IIF(Currency = 'CZK', 1, 0)) AS ratio FROM customers
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
Year 2012 can be presented as Between 201201 And 201212; The first 4 strings of the Date values in the yearmonth table can represent year.

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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: In 2012, who had the least consumption in LAM?
Evidence: Year 2012 can be presented as Between 201201 And 201212; The first 4 strings of the Date values in the yearmonth table can represent year.
Answer: SELECT T1.CustomerID 
FROM customers AS T1 
INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID 
WHERE T1.Segment = 'LAM' 
  AND SUBSTR(T2.Date, 1, 4) = '2012' 
GROUP BY T1.CustomerID 
ORDER BY SUM(T2.Consumption) ASC, T1.CustomerID ASC 
LIMIT 1;
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT T1.CustomerID 
FROM customers AS T1 
INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID 
WHERE T1.Segment = 'LAM' 
  AND SUBSTR(T2.Date, 1, 4) = '2012' 
GROUP BY T1.CustomerID 
ORDER BY SUM(T2.Consumption) ASC, T1.CustomerID ASC 
LIMIT 1;
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
Average Monthly consumption = AVG(Consumption) / 12; Year 2013 can be presented as Between 201301 And 201312; The first 4 strings of the Date values in the yearmonth table can represent year.

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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 was the average monthly consumption of customers in SME for the year 2013?
Evidence: Average Monthly consumption = AVG(Consumption) / 12; Year 2013 can be presented as Between 201301 And 201312; The first 4 strings of the Date values in the yearmonth table can represent year.
Answer: SELECT AVG(T2.Consumption) / 12 FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE SUBSTR(T2.Date, 1, 4) = '2013' AND T1.Segment = 'SME'
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT AVG(T2.Consumption) / 12 FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE SUBSTR(T2.Date, 1, 4) = '2013' AND T1.Segment = 'SME'
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
Year 2011 can be presented as Between 201101 And 201112, which means between January and December in 2011

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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: Which customers, paying in CZK, consumed the most gas in 2011?
Evidence: Year 2011 can be presented as Between 201101 And 201112, which means between January and December in 2011
Answer: SELECT T1.CustomerID FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Currency = 'CZK' AND T2.Date BETWEEN 201101 AND 201112 GROUP BY T1.CustomerID ORDER BY SUM(T2.Consumption) DESC, T1.CustomerID ASC LIMIT 1
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT T1.CustomerID FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Currency = 'CZK' AND T2.Date BETWEEN 201101 AND 201112 GROUP BY T1.CustomerID ORDER BY SUM(T2.Consumption) DESC, T1.CustomerID ASC LIMIT 1
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
Year 2012 can be presented as Between 201201 And 201212, which means between January and December in 2012

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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 customers in KAM had a consumption of less than 30,000 for the year 2012?
Evidence: Year 2012 can be presented as Between 201201 And 201212, which means between January and December in 2012
Answer: SELECT COUNT(*) FROM ( SELECT T2.CustomerID FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Segment = 'KAM' AND SUBSTRING(T2.Date, 1, 4) = '2012' GROUP BY T2.CustomerID HAVING SUM(T2.Consumption) < 30000 ) AS t1
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT COUNT(*) FROM ( SELECT T2.CustomerID FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Segment = 'KAM' AND SUBSTRING(T2.Date, 1, 4) = '2012' GROUP BY T2.CustomerID HAVING SUM(T2.Consumption) < 30000 ) AS t1
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
Year 2012 can be presented as Between 201201 And 201212; The first 4 strings of the Date values in the yearmonth table can represent year; Difference in Consumption = CZK customers consumption in 2012 - EUR customers consumption in 2012

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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 was the difference in gas consumption between CZK-paying customers and EUR-paying customers in 2012?
Evidence: Year 2012 can be presented as Between 201201 And 201212; The first 4 strings of the Date values in the yearmonth table can represent year; Difference in Consumption = CZK customers consumption in 2012 - EUR customers consumption in 2012
Answer: SELECT SUM(IIF(T1.Currency = 'CZK', T2.Consumption, 0)) - SUM(IIF(T1.Currency = 'EUR', T2.Consumption, 0)) FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE SUBSTR(T2.Date, 1, 4) = '2012'
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT SUM(IIF(T1.Currency = 'CZK', T2.Consumption, 0)) - SUM(IIF(T1.Currency = 'EUR', T2.Consumption, 0)) FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE SUBSTR(T2.Date, 1, 4) = '2012'
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
N/A

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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: Which year recorded the most gas use paid in EUR?
Answer: SELECT SUBSTRING(T2.Date, 1, 4) FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Currency = 'EUR' GROUP BY SUBSTRING(T2.Date, 1, 4) ORDER BY SUM(T2.Consumption) DESC LIMIT 1
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT SUBSTRING(T2.Date, 1, 4) FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Currency = 'EUR' GROUP BY SUBSTRING(T2.Date, 1, 4) ORDER BY SUM(T2.Consumption) DESC LIMIT 1
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
N/A

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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: Which segment had the least consumption?
Answer: SELECT T1.Segment FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID GROUP BY T1.Segment ORDER BY SUM(T2.Consumption) ASC LIMIT 1
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT T1.Segment FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID GROUP BY T1.Segment ORDER BY SUM(T2.Consumption) ASC LIMIT 1
##Instruction:
Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Database: debit_card_specializing
Total Tables: 5
Total Columns: 21

Table Schemas:

Table: customers (3 columns)
----------------------------
• CustomerID (integer): identification of the customer
• Segment (text): client segment
• Currency (text): Currency

Table: gasstations (4 columns)
------------------------------
• GasStationID (integer): Gas Station ID
• ChainID (integer): Chain ID
• Country (text)
• Segment (text): chain segment

Table: products (2 columns)
---------------------------
• ProductID (integer): Product ID
• Description (text): Description

Table: transactions_1k (9 columns)
----------------------------------
• TransactionID (integer): Transaction ID
• Date (date): Date
• Time (text): Time
• CustomerID (integer): Customer ID
• CardID (integer): Card ID
• GasStationID (integer): Gas Station ID
• ProductID (integer): Product ID
• Amount (integer): Amount
• Price (real): Price
  Values: commonsense evidence:

total price = Amount x Price

Table: yearmonth (3 columns)
----------------------------
• CustomerID (integer): Customer ID
• Date (text): Date
• Consumption (real): consumption

##Evidence:
The first 4 strings of the Date values in the yearmonth table can represent year.

##Role Access Policy (Column-Level):
Role: MarketingSpecialist
Accessible Columns: customers: CustomerID, Segment, Currency; yearmonth: CustomerID, Date, Consumption; transactions_1k: CustomerID, Date, ProductID; products: ProductID, Description

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: Which year recorded the most consumption of gas paid in CZK?
Evidence: The first 4 strings of the Date values in the yearmonth table can represent year.
Answer: SELECT SUBSTR(T2.Date, 1, 4) FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Currency = 'CZK' GROUP BY SUBSTR(T2.Date, 1, 4) ORDER BY SUM(T2.Consumption) DESC LIMIT 1
Permission: allowed (All required columns are permitted)
Gold SQL: SELECT SUBSTR(T2.Date, 1, 4) FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Currency = 'CZK' GROUP BY SUBSTR(T2.Date, 1, 4) ORDER BY SUM(T2.Consumption) DESC LIMIT 1