##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:
Double bonds refer to bond_type = '='. Only consider molecules that contain at least one double bond.

##Role Access Policy (Column-Level):
Role: DataOperator_1
Accessible Columns: atom: ALL COLUMNS; bond: ALL COLUMNS; molecule: 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: For each element that participates in double bonds, what is the count of atoms, the number of molecules containing them, their percentage of all atoms in the database, and examples of up to 3 molecules (with labels) where they appear in double bonds?
Evidence: Double bonds refer to bond_type = '='. Only consider molecules that contain at least one double bond.
Answer: Sorry, I cannot answer.
Permission: denied (Missing column permissions: connected: atom_id, bond_id)
Gold SQL: WITH ElementsInDoubleBonds AS (
    SELECT 
        T1.element,
        T1.atom_id,
        T1.molecule_id
    FROM 
        atom AS T1
    INNER JOIN 
        connected AS T3 ON T1.atom_id = T3.atom_id
    INNER JOIN 
        bond AS T2 ON T3.bond_id = T2.bond_id
    WHERE 
        T2.bond_type = '='
),
MoleculeStats AS (
    SELECT 
        m.molecule_id,
        m.label,
        COUNT(DISTINCT a.atom_id) AS total_atoms,
        COUNT(DISTINCT b.bond_id) AS total_bonds,
        SUM(CASE WHEN b.bond_type = '=' THEN 1 ELSE 0 END) AS double_bonds_count
    FROM 
        molecule m
    LEFT JOIN 
        atom a ON m.molecule_id = a.molecule_id
    LEFT JOIN 
        bond b ON m.molecule_id = b.molecule_id
    GROUP BY 
        m.molecule_id, m.label
    HAVING 
        double_bonds_count > 0
)
SELECT 
    e.element,
    COUNT(DISTINCT e.atom_id) AS atom_count,
    COUNT(DISTINCT e.molecule_id) AS molecule_count,
    ROUND(COUNT(DISTINCT e.atom_id) * 100.0 / (SELECT COUNT(*) FROM atom), 2) AS percentage_of_all_atoms,
    (
        SELECT GROUP_CONCAT(ms.molecule_id || ' (' || ms.label || ')', ', ')
        FROM MoleculeStats ms
        WHERE ms.molecule_id IN (SELECT DISTINCT edb.molecule_id FROM ElementsInDoubleBonds edb WHERE edb.element = e.element)
        LIMIT 3
    ) AS sample_molecules
FROM 
    ElementsInDoubleBonds e
GROUP BY 
    e.element
ORDER BY 
    atom_count DESC, 
    e.element ASC;