##Instruction:
Database: california_schools
Total Tables: 3
Total Columns: 89

Table Schemas:

Database: california_schools
Total Tables: 3
Total Columns: 89

Table Schemas:

Table: frpm (29 columns)
------------------------
• CDSCode (integer): CDSCode
• Academic Year (integer): Academic Year
• County Code (integer): County Code
• District Code (integer): District Code
• School Code (integer): School Code
• County Name (text): County Code
• District Name (text): District Name
• School Name (text): School Name
• District Type (text): District Type
• School Type (text): School Type
• Educational Option Type (text): Educational Option Type
• NSLP Provision Status (text): NSLP Provision Status
• Charter School (Y/N) (integer): Charter School (Y/N)
  Values: 0: N;
1: Y
• Charter School Number (text): Charter School Number
• Charter Funding Type (text): Charter Funding Type
• IRC (integer)
  Values: Not useful
• Low Grade (text): Low Grade
• High Grade (text): High Grade
• Enrollment (K-12) (real): Enrollment (K-12)
  Values: commonsense evidence:

K-12: 1st grade - 12nd grade
• Free Meal Count (K-12) (real): Free Meal Count (K-12)
  Values: commonsense evidence:

eligible free rate = Free Meal Count / Enrollment
• Percent (%) Eligible Free (K-12) (real)
• FRPM Count (K-12) (real): Free or Reduced Price Meal Count (K-12)
  Values: commonsense evidence:

eligible FRPM rate = FRPM / Enrollment
• Percent (%) Eligible FRPM (K-12) (real)
• Enrollment (Ages 5-17) (real): Enrollment (Ages 5-17)
• Free Meal Count (Ages 5-17) (real): Free Meal Count (Ages 5-17)
  Values: commonsense evidence:

eligible free rate = Free Meal Count / Enrollment
• Percent (%) Eligible Free (Ages 5-17) (real)
• FRPM Count (Ages 5-17) (real)
• Percent (%) Eligible FRPM (Ages 5-17) (real)
• 2013-14 CALPADS Fall 1 Certification Status (integer): 2013-14 CALPADS Fall 1 Certification Status

Table: satscores (11 columns)
-----------------------------
• cds (text): California Department Schools
• rtype (text): rtype
  Values: unuseful
• sname (text): school name
• dname (text): district segment
• cname (text): county name
• enroll12 (integer): enrollment (1st-12nd grade)
• NumTstTakr (integer): Number of Test Takers in this school
  Values: number of test takers in each school
• AvgScrRead (integer): average scores in Reading
  Values: average scores in Reading
• AvgScrMath (integer): average scores in Math
  Values: average scores in Math
• AvgScrWrite (integer): average scores in writing
  Values: average scores in writing
• NumGE1500 (integer): Number of Test Takers Whose Total SAT Scores Are Greater or Equal to 1500
  Values: Number of Test Takers Whose Total SAT Scores Are Greater or Equal to 1500

commonsense evidence:

Ex...

Table: schools (49 columns)
---------------------------
• CDSCode (text): CDSCode
• NCESDist (text): This field represents the 7-digit National Center for Educational Statistics (NCES) school district identification number. The first 2 digits identify the state and the last 5 digits identify the school district. Combined, they make a unique 7-digit ID for each school district.
• NCESSchool (text): This field represents the 5-digit NCES school identification number. The NCESSchool combined with the NCESDist form a unique 12-digit ID for each school.
• StatusType (text): This field identifies the status of the district.
  Values: Definitions of the valid status types are listed below:
·       Active: The district is in operation...
• County (text): County name
• District (text): District
• School (text): School
• Street (text): Street
• StreetAbr (text): The abbreviated street address of the school, district, or administrative authority’s physical location.
  Values: The abbreviated street address of the school, district, or administrative authority’s physical locat...
• City (text): City
• Zip (text): Zip
• State (text): State
• MailStreet (text): MailStreet
  Values: The unabbreviated mailing address of the school, district, or administrative authority. Note: 1) Som...
• MailStrAbr (text)
  Values: the abbreviated mailing street address of the school, district, or administrative authority.Note: Ma...
• MailCity (text)
  Values: The city associated with the mailing address of the school, district, or administrative authority. N...
• MailZip (text)
  Values: The zip code associated with the mailing address of the school, district, or administrative authorit...
• MailState (text)
  Values: The state within the mailing address. For your convenience we have filled the unpopulated MailState ...
• Phone (text): Phone
• Ext (text): The phone number extension of the school, district, or administrative authority.
  Values: The phone number extension of the school, district, or administrative authority.
• Website (text): The website address of the school, district, or administrative authority.
  Values: The website address of the school, district, or administrative authority.
• OpenDate (date): The date the school opened.
• ClosedDate (date): The date the school closed.
• Charter (integer): This field identifies a charter school.
  Values: The field is coded as follows:

·       1 = The school is a charter

·       0 = The school is not a...
• CharterNum (text): The charter school number,
  Values: 4-digit number assigned to a charter school.
• FundingType (text): Indicates the charter school funding type
  Values: Values are as follows:

·       Not in CS (California School) funding model

·       Locally funded
...
• DOC (text): District Ownership Code
  Values: The District Ownership Code (DOC) is the numeric code used to identify the category of the Administr...
• DOCType (text): The District Ownership Code Type is the text description of the DOC category.
  Values: (See text values in DOC field description above)
• SOC (text): The School Ownership Code is a numeric code used to identify the type of school.
  Values: •      08 - Preschool      
•       09 – Special Education Schools (Public)
•      11 – Youth Author...
• SOCType (text): The School Ownership Code Type is the text description of the type of school.
  Values: The School Ownership Code Type is the text description of the type of school.
• EdOpsCode (text): The Education Option Code is a short text description of the type of education offered.
  Values: •      ALTSOC – Alternative School of Choice
•      COMM – County Community School
•       COMMDAY –...
• EdOpsName (text): Educational Option Name
  Values: The Educational Option Name is the long text description of the type of education being offered.
• EILCode (text): The Educational Instruction Level Code is a short text description of the institution's type relative to the grade range served.
  Values: •       A – Adult
•       ELEM – Elementary
•       ELEMHIGH – Elementary-High Combination
•       H...
• EILName (text): The Educational Instruction Level Name is the long text description of the institution’s type relative to the grade range served.
  Values: The Educational Instruction Level Name is the long text description of the institution’s type relati...
• GSoffered (text): The grade span offered is the lowest grade and the highest grade offered or supported by the school, district, or administrative authority. This field might differ from the grade span served as reported in the most recent certified California Longitudinal Pupil Achievement (CALPADS) Fall 1 data collection.
  Values: For example XYZ School might display the following data:

GSoffered = P–Adult

GSserved = K–12
• GSserved (text): It is the lowest grade and the highest grade of student enrollment as reported in the most recent certified CALPADS Fall 1 data collection. Only K–12 enrollment is reported through CALPADS. This field may differ from the grade span offered.
  Values: commonsense evidence:

1.     Only K–12 enrollment is reported through CALPADS

2.     Note: Special...
• Virtual (text): This field identifies the type of virtual instruction offered by the school. Virtual instruction is instruction in which students and teachers are separated by time and/or location, and interaction occurs via computers and/or telecommunications technologies.
  Values: The field is coded as follows:

·       F = Exclusively Virtual – The school has no physical buildin...
• Magnet (integer): This field identifies whether a school is a magnet school and/or provides a magnet program.
  Values: The field is coded as follows:

·       1 = Magnet - The school is a magnet school and/or offers a m...
• Latitude (real): The angular distance (expressed in degrees) between the location of the school, district, or administrative authority and the equator measured north to south.
  Values: The angular distance (expressed in degrees) between the location of the school, district, or adminis...
• Longitude (real): The angular distance (expressed in degrees) between the location of the school, district, or administrative authority and the prime meridian (Greenwich, England) measured from west to east.
  Values: The angular distance (expressed in degrees) between the location of the school, district, or adminis...
• AdmFName1 (text): administrator's first name
  Values: The superintendent’s or principal’s first name.

commonsense evidence:

Only active and pending dist...
• AdmLName1 (text): administrator's last name
  Values: The superintendent’s or principal’s last name.

commonsense evidence:
Only active and pending distri...
• AdmEmail1 (text): administrator's email address
  Values: The superintendent’s or principal’s email address.

commonsense evidence:

Only active and pending d...
• AdmFName2 (text)
  Values: SAME as 1
• AdmLName2 (text)
• AdmEmail2 (text)
• AdmFName3 (text)
  Values: not useful
• AdmLName3 (text)
  Values: not useful
• AdmEmail3 (text)
  Values: not useful
• LastUpdate (date)
  Values: when is this record updated last time

##Evidence:
High FRPM refers to schools where Percent (%) Eligible FRPM (K-12) > 0.5. Total SAT Score is the sum of average reading, math, and writing scores. All ratios are calculated as Colusa County value divided by Humboldt County value.

##Role Access Policy (Column-Level):
Role: DataOperator_3
Accessible Columns: satscores: AvgScrMath, AvgScrRead, AvgScrWrite, NumGE1500, cds, cname, dname, rtype, sname; schools: ALL COLUMNS

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 ratios comparing various educational metrics between schools in Colusa County and Humboldt County in California, including total number of schools, charter schools, schools with high free meal eligibility rates, average SAT scores, total students receiving free or reduced-price meals, and total enrollment?
Evidence: High FRPM refers to schools where Percent (%) Eligible FRPM (K-12) > 0.5. Total SAT Score is the sum of average reading, math, and writing scores. All ratios are calculated as Colusa County value divided by Humboldt County value.
Answer: Sorry, I cannot answer.
Permission: denied (Missing column permissions: satscores: NumTstTakr; frpm: CDSCode, Enrollment (K-12), FRPM Count (K-12), Percent (%) Eligible FRPM (K-12))
Gold SQL: WITH ColusaSchools AS (
    SELECT 
        s.CDSCode,
        s.School,
        s.County,
        s.Charter,
        f.`FRPM Count (K-12)`,
        f.`Enrollment (K-12)`,
        CASE 
            WHEN f.`Percent (%) Eligible FRPM (K-12)` > 0.5 THEN 'High FRPM'
            ELSE 'Low FRPM'
        END AS FRPM_Category,
        sat.NumTstTakr,
        sat.AvgScrRead + sat.AvgScrMath + sat.AvgScrWrite AS TotalSATScore
    FROM schools s
    LEFT JOIN frpm f ON s.CDSCode = f.CDSCode
    LEFT JOIN satscores sat ON s.CDSCode = sat.cds
    WHERE s.MailState = 'CA' AND s.County = 'Colusa'
),
HumboldtSchools AS (
    SELECT 
        s.CDSCode,
        s.School,
        s.County,
        s.Charter,
        f.`FRPM Count (K-12)`,
        f.`Enrollment (K-12)`,
        CASE 
            WHEN f.`Percent (%) Eligible FRPM (K-12)` > 0.5 THEN 'High FRPM'
            ELSE 'Low FRPM'
        END AS FRPM_Category,
        sat.NumTstTakr,
        sat.AvgScrRead + sat.AvgScrMath + sat.AvgScrWrite AS TotalSATScore
    FROM schools s
    LEFT JOIN frpm f ON s.CDSCode = f.CDSCode
    LEFT JOIN satscores sat ON s.CDSCode = sat.cds
    WHERE s.MailState = 'CA' AND s.County = 'Humboldt'
),
ColosaStats AS (
    SELECT
        COUNT(*) AS TotalSchools,
        SUM(CASE WHEN Charter = 1 THEN 1 ELSE 0 END) AS CharterSchools,
        SUM(CASE WHEN FRPM_Category = 'High FRPM' THEN 1 ELSE 0 END) AS HighFRPMSchools,
        AVG(CASE WHEN TotalSATScore IS NOT NULL THEN TotalSATScore ELSE NULL END) AS AvgSATScore,
        SUM(`FRPM Count (K-12)`) AS TotalFRPMStudents,
        SUM(`Enrollment (K-12)`) AS TotalEnrollment
    FROM ColusaSchools
),
HumboldtStats AS (
    SELECT
        COUNT(*) AS TotalSchools,
        SUM(CASE WHEN Charter = 1 THEN 1 ELSE 0 END) AS CharterSchools,
        SUM(CASE WHEN FRPM_Category = 'High FRPM' THEN 1 ELSE 0 END) AS HighFRPMSchools,
        AVG(CASE WHEN TotalSATScore IS NOT NULL THEN TotalSATScore ELSE NULL END) AS AvgSATScore,
        SUM(`FRPM Count (K-12)`) AS TotalFRPMStudents,
        SUM(`Enrollment (K-12)`) AS TotalEnrollment
    FROM HumboldtSchools
)
SELECT 
    'Total Schools Ratio' AS Metric,
    CAST(c.TotalSchools AS REAL) / h.TotalSchools AS Ratio
FROM ColosaStats c, HumboldtStats h

UNION ALL

SELECT 
    'Charter Schools Ratio' AS Metric,
    CASE 
        WHEN h.CharterSchools = 0 THEN NULL
        ELSE CAST(c.CharterSchools AS REAL) / h.CharterSchools
    END AS Ratio
FROM ColosaStats c, HumboldtStats h

UNION ALL

SELECT 
    'High FRPM Schools Ratio' AS Metric,
    CASE 
        WHEN h.HighFRPMSchools = 0 THEN NULL
        ELSE CAST(c.HighFRPMSchools AS REAL) / h.HighFRPMSchools
    END AS Ratio
FROM ColosaStats c, HumboldtStats h

UNION ALL

SELECT 
    'Average SAT Score Ratio' AS Metric,
    CASE 
        WHEN h.AvgSATScore = 0 THEN NULL
        ELSE CAST(c.AvgSATScore AS REAL) / h.AvgSATScore
    END AS Ratio
FROM ColosaStats c, HumboldtStats h

UNION ALL

SELECT 
    'FRPM Students Ratio' AS Metric,
    CASE 
        WHEN h.TotalFRPMStudents = 0 THEN NULL
        ELSE CAST(c.TotalFRPMStudents AS REAL) / h.TotalFRPMStudents
    END AS Ratio
FROM ColosaStats c, HumboldtStats h

UNION ALL

SELECT 
    'Total Enrollment Ratio' AS Metric,
    CASE 
        WHEN h.TotalEnrollment = 0 THEN NULL
        ELSE CAST(c.TotalEnrollment AS REAL) / h.TotalEnrollment
    END AS Ratio
FROM ColosaStats c, HumboldtStats h;