Dludora/DAIL-BIRD huggingface dataset:
/* Given the following database schema: */
CREATE TABLE incidents
(
    case_number                TEXT  not null
        primary key,
    date                       DATE          not null,
    location                   TEXT  not null,
    subject_statuses           TEXT  not null,
    subject_weapon             TEXT  not null,
    subjects                   TEXT  not null,
    subject_count              INTEGER           not null,
    officers                  TEXT not null

)

CREATE TABLE officers
(
    case_number TEXT not null,
    race        TEXT         null,
    gender      TEXT         not null,
    last_name   TEXT not null,
    first_name  TEXT null,
    full_name   TEXT not null,
    foreign key (case_number) references incidents (case_number)
)

CREATE TABLE subjects
(
    case_number TEXT not null,
    race        TEXT         not null,
    gender      TEXT         not null,
    last_name   TEXT not null,
    first_name  TEXT null,
    full_name   TEXT not null,
    foreign key (case_number) references incidents (case_number)
)

/* Answer the following: What percentage of deaths were caused by rifles? rifle refers to subject_weapon = 'rifles'; death refers to subject_statuses = 'Deceased'; percentage = divide(count(incidents where subject_weapon = 'rifles'), count(incidents)) where subject_statuses = 'Deceased' * 100% */
SELECT 
SELECT CAST(SUM(subject_statuses = 'Deceased') AS REAL) * 100 / COUNT(case_number) FROM incidents WHERE subject_weapon = 'Rifle'
/* Given the following database schema: */
CREATE TABLE incidents
(
    case_number                TEXT  not null
        primary key,
    date                       DATE          not null,
    location                   TEXT  not null,
    subject_statuses           TEXT  not null,
    subject_weapon             TEXT  not null,
    subjects                   TEXT  not null,
    subject_count              INTEGER           not null,
    officers                  TEXT not null

)

CREATE TABLE officers
(
    case_number TEXT not null,
    race        TEXT         null,
    gender      TEXT         not null,
    last_name   TEXT not null,
    first_name  TEXT null,
    full_name   TEXT not null,
    foreign key (case_number) references incidents (case_number)
)

CREATE TABLE subjects
(
    case_number TEXT not null,
    race        TEXT         not null,
    gender      TEXT         not null,
    last_name   TEXT not null,
    first_name  TEXT null,
    full_name   TEXT not null,
    foreign key (case_number) references incidents (case_number)
)

/* Answer the following: Which type of weapon was used to attack the victim in the record number 031347-2015? What is the victim's race and gender? type of weapon refers to subject_weapon; record number 031347-2015 refers to case_number = '031347-2015' */
SELECT 
SELECT T1.subject_weapon, T2.race, T2.gender FROM incidents AS T1 INNER JOIN subjects AS T2 ON T1.case_number = T2.case_number WHERE T1.case_number = '031347-2015'
/* Given the following database schema: */
CREATE TABLE incidents
(
    case_number                TEXT  not null
        primary key,
    date                       DATE          not null,
    location                   TEXT  not null,
    subject_statuses           TEXT  not null,
    subject_weapon             TEXT  not null,
    subjects                   TEXT  not null,
    subject_count              INTEGER           not null,
    officers                  TEXT not null

)

CREATE TABLE officers
(
    case_number TEXT not null,
    race        TEXT         null,
    gender      TEXT         not null,
    last_name   TEXT not null,
    first_name  TEXT null,
    full_name   TEXT not null,
    foreign key (case_number) references incidents (case_number)
)

CREATE TABLE subjects
(
    case_number TEXT not null,
    race        TEXT         not null,
    gender      TEXT         not null,
    last_name   TEXT not null,
    first_name  TEXT null,
    full_name   TEXT not null,
    foreign key (case_number) references incidents (case_number)
)

/* Answer the following: Which near-death incident did a policeman by the name of Ruben Fredirick look into? What is the victim in this incident's race and gender? near-death refers to subject_statuses = 'Deceased Injured'; incident refers to case_number; Ruben Fredirick refers to full_name = 'Ruben Fredirick' */
SELECT 
SELECT T1.case_number, T3.race, T3.gender FROM incidents AS T1 INNER JOIN officers AS T2 ON T1.case_number = T2.case_number INNER JOIN subjects AS T3 ON T1.case_number = T3.case_number WHERE T2.first_name = 'Fredirick' AND T2.last_name = 'Ruben'
/* Given the following database schema: */
CREATE TABLE incidents
(
    case_number                TEXT  not null
        primary key,
    date                       DATE          not null,
    location                   TEXT  not null,
    subject_statuses           TEXT  not null,
    subject_weapon             TEXT  not null,
    subjects                   TEXT  not null,
    subject_count              INTEGER           not null,
    officers                  TEXT not null

)

CREATE TABLE officers
(
    case_number TEXT not null,
    race        TEXT         null,
    gender      TEXT         not null,
    last_name   TEXT not null,
    first_name  TEXT null,
    full_name   TEXT not null,
    foreign key (case_number) references incidents (case_number)
)

CREATE TABLE subjects
(
    case_number TEXT not null,
    race        TEXT         not null,
    gender      TEXT         not null,
    last_name   TEXT not null,
    first_name  TEXT null,
    full_name   TEXT not null,
    foreign key (case_number) references incidents (case_number)
)

/* Answer the following: What proportion of male police officers looked into events where people were injured? male refers to gender = 'M'; people were injured refers to subject_statuses = 'Injured'; proportion = divide(count(case_number where gender = 'M'), count(case_number)) where subject_statuses = 'Injured' * 100% */
SELECT 
SELECT CAST(SUM(T2.gender = 'M') AS REAL) * 100 / COUNT(T1.case_number) FROM incidents T1 INNER JOIN officers T2 ON T1.case_number = T2.case_number WHERE T1.subject_statuses = 'Injured'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: For the genes that are located in the plasma membrane, please list their number of chromosomes. */
SELECT 
SELECT T1.Chromosome FROM Genes AS T1 INNER JOIN Classification AS T2 ON T1.GeneID = T2.GeneID WHERE T2.Localization = 'plasma membrane'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: How many non-essential genes are located in the nucleus? */
SELECT 
SELECT COUNT(T1.GeneID) FROM Genes AS T1 INNER JOIN Classification AS T2 ON T1.GeneID = T2.GeneID WHERE T2.Localization = 'nucleus' AND T1.Essential = 'Non-Essential'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Among the genes with nucleic acid metabolism defects, how many of them can be found in the vacuole? */
SELECT 
SELECT COUNT(T1.GeneID) FROM Genes AS T1 INNER JOIN Classification AS T2 ON T1.GeneID = T2.GeneID WHERE T2.Localization = 'vacuole' AND T1.Phenotype = 'Nucleic acid metabolism defects'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Please list the location of the genes that have the most chromosomes. */
SELECT 
SELECT T2.Localization FROM Genes AS T1 INNER JOIN Classification AS T2 ON T1.GeneID = T2.GeneID ORDER BY T1.Chromosome DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Among the pairs of genes that are both located in the nucleus, what is the highest expression correlation score? */
SELECT 
SELECT T2.Expression_Corr FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 INNER JOIN Genes AS T3 ON T3.GeneID = T2.GeneID2 WHERE T1.Localization = 'nucleus' AND T3.Localization = 'nucleus' ORDER BY T2.Expression_Corr DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: What are the functions of the pair of genes that have the lowest expression correlation score?a */
SELECT 
SELECT T1.Function FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 ORDER BY T2.Expression_Corr ASC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Among the pairs of genes that are not from the class of motorproteins, how many of them are negatively correlated? If Expression_Corr < 0, it means the negatively correlated */
SELECT 
SELECT COUNT(T1.GeneID) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T2.Expression_Corr < 0 AND T1.Class = 'Motorproteins'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: For the pairs of genes with one having 8 chromosomes and the other having 6 chromosomes, what is the highest expression correlation score? */
SELECT 
SELECT T2.Expression_Corr FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Chromosome = 6 OR T1.Chromosome = 8 ORDER BY T2.Expression_Corr DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Please list the motif of the genes that are located in the cytoplasm and have 7 chromosomes. */
SELECT 
SELECT T2.GeneID1, T2.GeneID2 FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Localization = 'cytoplasm' AND T1.Chromosome = 7
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: For the non-essential genes whose functions are transcription, how many of them are not located in the cytoplasm? */
SELECT 
SELECT COUNT(T1.GeneID) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Localization != 'cytoplasm' AND T1.Function = 'TRANSCRIPTION' AND T1.Essential = 'NON-Essential'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: How many pairs of positively correlated genes are both non-essential? If Expression_Corr > 0, it means the expression correlation is positive */
SELECT 
SELECT COUNT(T2.GeneID2) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T2.Expression_Corr > 0 AND T1.Essential = 'Non-Essential'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: If a pair of genes is positively correlated, what is the possibility of it being composed of two genes both with over 10 chromosomes? Positively correlated means Expression_Corr > 0; Possibility = count(the pairs of genes with both chromosomes over 20) / count(pairs of genes that are positively correlated) */
SELECT 
SELECT CAST(SUM(IIF(T1.Chromosome > 10 AND T3.Chromosome > 10, 1, 0)) AS REAL) * 100 / COUNT(T1.GeneID) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 INNER JOIN Genes AS T3 ON T3.GeneID = T2.GeneID2 WHERE T2.Expression_Corr > 0
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: For the pairs of genes both from the class ATPases, what is the average expression correlation score? */
SELECT 
SELECT AVG(T2.Expression_Corr) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Class = 'ATPases'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Lists all genes by identifier number located in the cytoplasm and whose function is metabolism. */
SELECT 
SELECT DISTINCT GeneID FROM Genes WHERE Localization = 'cytoplasm' AND Function = 'METABOLISM'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: How many different genes do we have if we add those located in the plasma and in the nucleus? */
SELECT 
SELECT COUNT(GeneID) FROM Classification WHERE Localization IN ('plasma', 'nucleus')
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: What kind of expression correlation occurs in physical type interacting gene pairs and what percentage of these are negatively correlated? If the Expression_Corr value is negative then it's negatively correlated. Percentage of Negative Correlation = count(negative Expression_Corr physical type) / count(Expression_Corr physical type) * 100% */
SELECT 
SELECT Expression_Corr FROM Interactions WHERE Type = 'Physical' UNION ALL SELECT CAST(SUM(Expression_Corr < 0) AS REAL) * 100 / COUNT(*) FROM Interactions WHERE Type = 'Physical'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: What percentage of genes located in the cytoskeleton are of unknown class? And of these, how many are not conditional phenotypes? Percentage = count(genes located in the cytoskeleton unknown class) / count(genes located in the cytoskeleton) * 100% */
SELECT 
SELECT SUM(Localization = 'cytoskeleton' AND Phenotype = 'Conditional phenotypes') , CAST(SUM(Localization = 'cytoskeleton') AS REAL) * 100 / COUNT(GeneID) FROM Genes;
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: What type of interactions occurs in genes whose function is cellular transport and transport medicine and are classified as non-essential? */
SELECT 
SELECT T2.Type FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Function = 'TRANSCRIPTION' AND T1.Essential = 'Non-Essential'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: List all genes whose interaction is with genes located in the nucleus in which it is positively correlated. If the Expression_Corr value is positive then it's positively correlated */
SELECT 
SELECT T1.GeneID FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T2.Expression_Corr > 0 AND T1.Localization = 'nucleus'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Taking all the essential genes of the transcription factors class located in the nucleus as a reference, how many of them carry out a genetic-type interaction with another gene? List them. */
SELECT 
SELECT T2.GeneID1 FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Localization = 'nucleus' AND T1.Class = 'Transcription factors' AND T1.Essential = 'Essential' AND T2.Expression_Corr != 0
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Of all the nonessential genes that are not of the motorprotein class and whose phenotype is cell cycle defects, how many do not have a physical type of interaction? */
SELECT 
SELECT COUNT(T1.GeneID) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T2.Type != 'Physical' AND T1.Phenotype = 'Cell cycle defects' AND T1.Class != 'Motorproteins' AND T1.Essential = 'Non-Essential'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Of the genes whose phenotype and motif are nucleic acid metabolism defects, PS00107, what percentage perform positive interaction with another gene? Percentage of no interaction = [count(nucleic acid metabolism, PS00107, no interaction) / count(nucleic acid metabolism, PS00107) * 100% */
SELECT 
SELECT CAST(SUM(IIF(T2.Expression_Corr > 0, 1, 0)) AS REAL) * 100 / COUNT(T2.GeneID1) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T1.Phenotype = 'Nucleic acid metabolism defects' AND T1.Motif = 'PS00107'
/* Given the following database schema: */
CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
)

CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
)

CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
)

/* Answer the following: Which negatively correlated, genetically interacting genes are non-essential? What percentage do they represent with respect to those that are essential? If the Expression_Corr value is negative then it's negatively correlated; Percentage of Essensity = [count(negatively correlated, genetical interaction, non-essential) / count(negatively correlated, genetical interaction, non-essential+negatively correlated, genetical interaction, essential)] * 100% */
SELECT 
SELECT CAST(COUNT(T1.GeneID) AS REAL) * 100 / ( SELECT COUNT(T1.GeneID) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T2.Expression_Corr < 0 ) FROM Genes AS T1 INNER JOIN Interactions AS T2 ON T1.GeneID = T2.GeneID1 WHERE T2.Expression_Corr < 0 AND T1.Essential = 'Non-Essential'
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: How many apps were last updated in January of 2018? Please write one translated review with positive sentiment for each app, if there's any. updated in January of 2018 refers to Last Updated BETWEEN 'January 1, 2018' and 'January 31, 2018'; */
SELECT 
SELECT DISTINCT Translated_Review FROM user_reviews WHERE App IN ( SELECT App FROM playstore WHERE `Last Updated` BETWEEN 'January 1, 2018' AND 'January 31, 2018' ) AND Sentiment = 'Positive'
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: How many users mildly likes the 7 Minute Workout app and when was it last updated? mildly likes the app refers to Sentiment_Polarity> = 0 and Sentiment_Polarity<0.5; */
SELECT 
SELECT COUNT(T2.Sentiment_Polarity), T1."Last Updated" FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = '7 Minute Workout' AND T2.Sentiment_Polarity BETWEEN 0 AND 0.5
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: How many users holds neutral attitude towards the HTC Weather app? Indicate the app's rating on the Google Play Store. user holds neutral attitude refers to Sentiment = 'Neutral'; */
SELECT 
SELECT COUNT(T1.Rating), T1.Rating FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'HTC Weather' AND T2.Sentiment = 'Neutral'
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: What is the name and category of the app with the highest amount of -1 sentiment polarity score? highest amount of -1 sentiment polarity score refers to MAX(Count(Sentiment_Polarity = 1.0)) */
SELECT 
SELECT DISTINCT T1.App, T1.Category FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T2.Sentiment_Polarity = '-1.0'
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: What is the average sentiment polarity score of the Cooking Fever app? Indicate the age group that the app is targeted at. average sentiment polarity score = AVG(Sentiment_Polarity); age group the app is target at refers to Content Rating; */
SELECT 
SELECT AVG(T2.Sentiment_Polarity), T1."Content Rating" FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Cooking Fever'
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: What is the lowest sentiment polarity score of the Basketball Stars app for people who dislikes the app pretty much and how many downloads does it have? lowest sentiment polarity score refers to MIN(Sentiment_Polarity); user dislike the app pretty much refers to Sentiment_Polarity<-0.5; number of downloads it has refers to installs; */
SELECT 
SELECT MIN(T2.Sentiment_Polarity), T1.Installs FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Basketball Stars'
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: For the Akinator app, how many reviews have sentiment subjectivity of no more than 0.5 and what is its current version? Sentiment_Subjectivity<0.5; current version refers to Current Ver; */
SELECT 
SELECT COUNT(T2.Sentiment_Subjectivity), T1."Current Ver" FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = 'Akinator' AND T2.Sentiment_Subjectivity < 0.5
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: How many apps have rating of 5? FALSE; */
SELECT 
SELECT COUNT(App) FROM playstore WHERE Rating = 5
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: What are the top 5 installed free apps? free app refers to price = 0; most installed app refers to MAX(Installs); */
SELECT 
SELECT App FROM playstore WHERE Price = 0 ORDER BY CAST(REPLACE(REPLACE(Installs, ',', ''), '+', '') AS INTEGER) DESC LIMIT 5
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: Name the top 10 most reviewed apps. most reviewed app refers to MAX(Reviews); */
SELECT 
SELECT DISTINCT App FROM playstore ORDER BY Reviews DESC LIMIT 10
/* Given the following database schema: */
CREATE TABLE "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
)

CREATE TABLE "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
)

/* Answer the following: How many of the users hold neutral attitude on "10 Best Foods for You" app and what category is this app? neutral attitude refers to Sentiment = 'Neutral'; */
SELECT 
SELECT COUNT(T2.App), T1.Category FROM playstore AS T1 INNER JOIN user_reviews AS T2 ON T1.App = T2.App WHERE T1.App = '10 Best Foods for You' AND T2.Sentiment = 'Neutral'