##Instruction:
Database: student_club
Total Tables: 8
Total Columns: 48

Table Schemas:

Database: student_club
Total Tables: 8
Total Columns: 48

Table Schemas:

Table: attendance (2 columns)
-----------------------------
• link_to_event (text): The unique identifier of the event which was attended
  Values: References the Event table
• link_to_member (text): The unique identifier of the member who attended the event
  Values: References the Member table

Table: budget (7 columns)
-------------------------
• budget_id (text): A unique identifier for the budget entry
• category (text): The area for which the amount is budgeted, such as, advertisement, food, parking
• spent (real): The total amount spent in the budgeted category for an event.
  Values: the unit is dollar. This is summarized from the Expense table
• remaining (real): A value calculated as the amount budgeted minus the amount spent
  Values: the unit is dollar 
commonsense evidence: If the remaining < 0, it means that the cost has exceeded ...
• amount (integer): The amount budgeted for the specified category and event
  Values: the unit is dollar 
commonsense evidence:
some computation like: amount = spent + remaining
• event_status (text): the status of the event
  Values: Closed / Open/ Planning 
commonsense evidence: 
 Closed: It means that the event is closed. The spe...
• link_to_event (text): The unique identifier of the event to which the budget line applies.
  Values: References the Event table

Table: event (7 columns)
------------------------
• event_id (text): A unique identifier for the event
• event_name (text): event name
• event_date (text): The date the event took place or is scheduled to take place
  Values: e.g. 2020-03-10T12:00:00
• type (text): The kind of event, such as game, social, election
• notes (text): A free text field for any notes about the event
• location (text): Address where the event was held or is to be held or the name of such a location
• status (text): One of three values indicating if the event is in planning, is opened, or is closed
  Values: Open/ Closed/ Planning

Table: expense (7 columns)
--------------------------
• expense_id (text): unique id of income
• expense_description (text): A textual description of what the money was spend for
• expense_date (text): The date the expense was incurred
  Values: e.g. YYYY-MM-DD
• cost (real): The dollar amount of the expense
  Values: the unit is dollar
• approved (text): A true or false value indicating if the expense was approved
  Values: true/ false
• link_to_member (text): The member who incurred the expense
• link_to_budget (text): The unique identifier of the record in the Budget table that indicates the expected total expenditure for a given category and event.
  Values: References the Budget table

Table: income (6 columns)
-------------------------
• income_id (text): A unique identifier for each record of income
• date_received (text): the date that the fund received
• amount (integer): amount of funds
  Values: the unit is dollar
• source (text): A value indicating where the funds come from such as dues, or the annual university allocation
• notes (text): A free-text value giving any needed details about the receipt of funds
• link_to_member (text): link to member

Table: major (4 columns)
------------------------
• major_id (text): A unique identifier for each major
• major_name (text): major name
• department (text): The name of the department that offers the major
• college (text): The name college that houses the department that offers the major

Table: member (9 columns)
-------------------------
• member_id (text): unique id of member
• first_name (text): member's first name
• last_name (text): member's last name
  Values: commonsense evidence: 
full name is first_name + last_name. e.g. A member's first name is Angela and...
• email (text): member's email
• position (text): The position the member holds in the club
• t_shirt_size (text): The size of tee shirt that member wants when shirts are ordered
  Values: commonsense evidence: usually the student ordered t-shirt with lager size has bigger body shape
• phone (text): The best telephone at which to contact the member
• zip (integer): the zip code of the member's hometown
• link_to_major (text): The unique identifier of the major of the member. References the Major table

Table: zip_code (6 columns)
---------------------------
• zip_code (integer): The ZIP code itself. A five-digit number identifying a US post office.
• type (text): The kind of ZIP code
  Values: commonsense evidence: 
� Standard: the normal codes with which most people are familiar 
� PO Box:...
• city (text): The city to which the ZIP pertains
• county (text): The county to which the ZIP pertains
• state (text): The name of the state to which the ZIP pertains
• short_state (text): The abbreviation of the state to which the ZIP pertains

##Evidence:
went over budget refers to a budget record where remaining < 0; a "over-budget event" is an event with at least one over-budget budget record; percentage = (Number of over-budget events ÷ Total number of events) × 100, where "Number of over-budget events" = COUNT(DISTINCT event_id with remaining < 0), "Total number of events" = COUNT(DISTINCT event.event_id)

##Role Access Policy (Column-Level):
Role: MembershipManager
Accessible Columns: member: member_id, first_name, last_name, email, position, t_shirt_size, phone, zip, link_to_major; major: ALL COLUMNS; zip_code: ALL COLUMNS; attendance: link_to_event, link_to_member

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 percentage of the events that went over budget?
Evidence: went over budget refers to a budget record where remaining < 0; a "over-budget event" is an event with at least one over-budget budget record; percentage = (Number of over-budget events ÷ Total number of events) × 100, where "Number of over-budget events" = COUNT(DISTINCT event_id with remaining < 0), "Total number of events" = COUNT(DISTINCT event.event_id)
Answer: Sorry, I cannot answer.
Permission: denied (Missing column permissions: budget: link_to_event, remaining; event: event_id)
Gold SQL: SELECT 
    CAST(COUNT(DISTINCT CASE WHEN b.remaining < 0 THEN b.link_to_event END) AS REAL) 
    / COUNT(DISTINCT e.event_id) 
    * 100 AS over_budget_event_percentage
FROM event e
LEFT JOIN budget b ON e.event_id = b.link_to_event;