##Instruction:
Database: toxicology
Total Tables: 4
Total Columns: 11

Table Schemas:

Database: toxicology
Total Tables: 4
Total Columns: 11

Table Schemas:

Table: atom (3 columns)
-----------------------
• atom_id (text): the unique id of atoms
• molecule_id (text): identifying the molecule to which the atom belongs
  Values: commonsense evidence:
TRXXX_i represents ith atom of molecule TRXXX
• element (text): the element of the toxicology
  Values:  cl: chlorine
 c: carbon
 h: hydrogen
 o: oxygen
 s: sulfur
 n: nitrogen
 p: phosphorus
 na:...

Table: bond (3 columns)
-----------------------
• bond_id (text): unique id representing bonds
  Values: TRxxx_A1_A2:
TRXXX refers to which molecule
A1 and A2 refers to which atom
• molecule_id (text): identifying the molecule in which the bond appears
• bond_type (text): type of the bond
  Values: commonsense evidence:
-: single bond
'=': double bond
'#': triple bond

Table: connected (3 columns)
----------------------------
• atom_id (text): id of the first atom
• atom_id2 (text): id of the second atom
• bond_id (text): bond id representing bond between two atoms

Table: molecule (2 columns)
---------------------------
• molecule_id (text): unique id of molecule
  Values: "+" --> this molecule / compound is carcinogenic
'-' this molecule is not / compound carcinogenic
• label (text): whether this molecule is carcinogenic or not

##Evidence:
most common bond type refers to the bond_type with MAX(COUNT(bond_id)); molecule label refers to '+' for carcinogenic and '-' for non-carcinogenic

##Role Access Policy (Column-Level):
Role: MolecularViewer
Accessible Columns: molecule: ALL COLUMNS; atom: atom_id, element; bond: bond_id, bond_type

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: For the most common bond type in the database, provide comprehensive statistics including its total occurrences, how many molecules contain it, the average number of such bonds per molecule, the number of unique element pairs it connects, and which molecule labels (carcinogenic or non-carcinogenic) contain this bond type.
Evidence: most common bond type refers to the bond_type with MAX(COUNT(bond_id)); molecule label refers to '+' for carcinogenic and '-' for non-carcinogenic
Answer: Sorry, I cannot answer.
Permission: denied (Missing column permissions: connected: atom_id, atom_id2, bond_id; bond: molecule_id)
Gold SQL: WITH BondCounts AS (
    SELECT 
        b.bond_type,
        COUNT(b.bond_id) AS bond_count,
        RANK() OVER (ORDER BY COUNT(b.bond_id) DESC) AS bond_rank
    FROM bond b
    GROUP BY b.bond_type
),
MoleculeStats AS (
    SELECT 
        b.molecule_id,
        b.bond_type,
        COUNT(b.bond_id) AS bonds_per_molecule,
        m.label AS molecule_label
    FROM bond b
    JOIN molecule m ON b.molecule_id = m.molecule_id
    GROUP BY b.molecule_id, b.bond_type, m.label
),
AtomConnections AS (
    SELECT 
        b.bond_type,
        a1.element AS element1,
        a2.element AS element2,
        COUNT(*) AS connection_count
    FROM connected c
    JOIN bond b ON c.bond_id = b.bond_id
    JOIN atom a1 ON c.atom_id = a1.atom_id
    JOIN atom a2 ON c.atom_id2 = a2.atom_id
    GROUP BY b.bond_type, a1.element, a2.element
)
SELECT 
    bc.bond_type,
    bc.bond_count AS total_occurrences,
    COUNT(DISTINCT ms.molecule_id) AS molecules_containing,
    ROUND(AVG(ms.bonds_per_molecule), 2) AS avg_bonds_per_molecule,
    (SELECT COUNT(DISTINCT element1 || '-' || element2) 
     FROM AtomConnections ac 
     WHERE ac.bond_type = bc.bond_type) AS unique_element_pairs,
    GROUP_CONCAT(DISTINCT ms.molecule_label) AS molecule_labels
FROM BondCounts bc
JOIN MoleculeStats ms ON bc.bond_type = ms.bond_type
WHERE bc.bond_rank = 1
GROUP BY bc.bond_type, bc.bond_count
ORDER BY bc.bond_count DESC
LIMIT 1;