Instruction: Top Voted Questions By Tag.

Input:
CREATE TABLE ReviewTasks (
    Id number,
    ReviewTaskTypeId number,
    CreationDate time,
    DeletionDate time,
    ReviewTaskStateId number,
    PostId number,
    SuggestedEditId number,
    CompletedByReviewTaskId number
)

CREATE TABLE SuggestedEditVotes (
    Id number,
    SuggestedEditId number,
    UserId number,
    VoteTypeId number,
    CreationDate time,
    TargetUserId number,
    TargetRepChange number
)

CREATE TABLE ReviewTaskTypes (
    Id number,
    Name text,
    Description text
)

CREATE TABLE TagSynonyms (
    Id number,
    SourceTagName text,
    TargetTagName text,
    CreationDate time,
    OwnerUserId number,
    AutoRenameCount number,
    LastAutoRename time,
    Score number,
    ApprovedByUserId number,
    ApprovalDate time
)

CREATE TABLE PostTypes (
    Id number,
    Name text
)

CREATE TABLE PostsWithDeleted (
    Id number,
    PostTypeId number,
    AcceptedAnswerId number,
    ParentId number,
    CreationDate time,
    DeletionDate time,
    Score number,
    ViewCount number,
    Body text,
    OwnerUserId number,
    OwnerDisplayName text,
    LastEditorUserId number,
    LastEditorDisplayName text,
    LastEditDate time,
    LastActivityDate time,
    Title text,
    Tags text,
    AnswerCount number,
    CommentCount number,
    FavoriteCount number,
    ClosedDate time,
    CommunityOwnedDate time,
    ContentLicense text
)

CREATE TABLE ReviewRejectionReasons (
    Id number,
    Name text,
    Description text,
    PostTypeId number
)

CREATE TABLE VoteTypes (
    Id number,
    Name text
)

CREATE TABLE PostFeedback (
    Id number,
    PostId number,
    IsAnonymous boolean,
    VoteTypeId number,
    CreationDate time
)

CREATE TABLE PostHistory (
    Id number,
    PostHistoryTypeId number,
    PostId number,
    RevisionGUID other,
    CreationDate time,
    UserId number,
    UserDisplayName text,
    Comment text,
    Text text,
    ContentLicense text
)

CREATE TABLE Tags (
    Id number,
    TagName text,
    Count number,
    ExcerptPostId number,
    WikiPostId number
)

CREATE TABLE ReviewTaskResults (
    Id number,
    ReviewTaskId number,
    ReviewTaskResultTypeId number,
    CreationDate time,
    RejectionReasonId number,
    Comment text
)

CREATE TABLE Posts (
    Id number,
    PostTypeId number,
    AcceptedAnswerId number,
    ParentId number,
    CreationDate time,
    DeletionDate time,
    Score number,
    ViewCount number,
    Body text,
    OwnerUserId number,
    OwnerDisplayName text,
    LastEditorUserId number,
    LastEditorDisplayName text,
    LastEditDate time,
    LastActivityDate time,
    Title text,
    Tags text,
    AnswerCount number,
    CommentCount number,
    FavoriteCount number,
    ClosedDate time,
    CommunityOwnedDate time,
    ContentLicense text
)

CREATE TABLE CloseAsOffTopicReasonTypes (
    Id number,
    IsUniversal boolean,
    InputTitle text,
    MarkdownInputGuidance text,
    MarkdownPostOwnerGuidance text,
    MarkdownPrivilegedUserGuidance text,
    MarkdownConcensusDescription text,
    CreationDate time,
    CreationModeratorId number,
    ApprovalDate time,
    ApprovalModeratorId number,
    DeactivationDate time,
    DeactivationModeratorId number
)

CREATE TABLE PostTags (
    PostId number,
    TagId number
)

CREATE TABLE PostHistoryTypes (
    Id number,
    Name text
)

CREATE TABLE SuggestedEdits (
    Id number,
    PostId number,
    CreationDate time,
    ApprovalDate time,
    RejectionDate time,
    OwnerUserId number,
    Comment text,
    Text text,
    Title text,
    Tags text,
    RevisionGUID other
)

CREATE TABLE Votes (
    Id number,
    PostId number,
    VoteTypeId number,
    UserId number,
    CreationDate time,
    BountyAmount number
)

CREATE TABLE Comments (
    Id number,
    PostId number,
    Score number,
    Text text,
    CreationDate time,
    UserDisplayName text,
    UserId number,
    ContentLicense text
)

CREATE TABLE PostNoticeTypes (
    Id number,
    ClassId number,
    Name text,
    Body text,
    IsHidden boolean,
    Predefined boolean,
    PostNoticeDurationId number
)

CREATE TABLE Badges (
    Id number,
    UserId number,
    Name text,
    Date time,
    Class number,
    TagBased boolean
)

CREATE TABLE FlagTypes (
    Id number,
    Name text,
    Description text
)

CREATE TABLE ReviewTaskResultTypes (
    Id number,
    Name text,
    Description text
)

CREATE TABLE Users (
    Id number,
    Reputation number,
    CreationDate time,
    DisplayName text,
    LastAccessDate time,
    WebsiteUrl text,
    Location text,
    AboutMe text,
    Views number,
    UpVotes number,
    DownVotes number,
    ProfileImageUrl text,
    EmailHash text,
    AccountId number
)

CREATE TABLE ReviewTaskStates (
    Id number,
    Name text,
    Description text
)

CREATE TABLE PostLinks (
    Id number,
    CreationDate time,
    PostId number,
    RelatedPostId number,
    LinkTypeId number
)

CREATE TABLE CloseReasonTypes (
    Id number,
    Name text,
    Description text
)

CREATE TABLE PostNotices (
    Id number,
    PostId number,
    PostNoticeTypeId number,
    CreationDate time,
    DeletionDate time,
    ExpiryDate time,
    Body text,
    OwnerUserId number,
    DeletionUserId number
)

CREATE TABLE PendingFlags (
    Id number,
    FlagTypeId number,
    PostId number,
    CreationDate time,
    CloseReasonTypeId number,
    CloseAsOffTopicReasonTypeId number,
    DuplicateOfQuestionId number,
    BelongsOnBaseHostAddress text
)

Response: WITH ScoreByTag AS (SELECT pt.TagId, p.Score, ROW_NUMBER() OVER (PARTITION BY pt.TagId ORDER BY p.Score DESC) AS "rank" FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id) SELECT RANK() OVER (ORDER BY st.Score DESC) AS "rank", t.TagName, st.Score FROM ScoreByTag AS st INNER JOIN Tags AS t ON st.TagId = t.Id WHERE st.Rank = 1 ORDER BY st.Score DESC

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: Top Voted Questions By Tag. ### Input: CREATE TABLE ReviewTasks (
    Id number,
    ReviewTaskTypeId number,
    CreationDate time,
    DeletionDate time,
    ReviewTaskStateId number,
    PostId number,
    SuggestedEditId number,
    CompletedByReviewTaskId number
)

CREATE TABLE SuggestedEditVotes (
    Id number,
    SuggestedEditId number,
    UserId number,
    VoteTypeId number,
    CreationDate time,
    TargetUserId number,
    TargetRepChange number
)

CREATE TABLE ReviewTaskTypes (
    Id number,
    Name text,
    Description text
)

CREATE TABLE TagSynonyms (
    Id number,
    SourceTagName text,
    TargetTagName text,
    CreationDate time,
    OwnerUserId number,
    AutoRenameCount number,
    LastAutoRename time,
    Score number,
    ApprovedByUserId number,
    ApprovalDate time
)

CREATE TABLE PostTypes (
    Id number,
    Name text
)

CREATE TABLE PostsWithDeleted (
    Id number,
    PostTypeId number,
    AcceptedAnswerId number,
    ParentId number,
    CreationDate time,
    DeletionDate time,
    Score number,
    ViewCount number,
    Body text,
    OwnerUserId number,
    OwnerDisplayName text,
    LastEditorUserId number,
    LastEditorDisplayName text,
    LastEditDate time,
    LastActivityDate time,
    Title text,
    Tags text,
    AnswerCount number,
    CommentCount number,
    FavoriteCount number,
    ClosedDate time,
    CommunityOwnedDate time,
    ContentLicense text
)

CREATE TABLE ReviewRejectionReasons (
    Id number,
    Name text,
    Description text,
    PostTypeId number
)

CREATE TABLE VoteTypes (
    Id number,
    Name text
)

CREATE TABLE PostFeedback (
    Id number,
    PostId number,
    IsAnonymous boolean,
    VoteTypeId number,
    CreationDate time
)

CREATE TABLE PostHistory (
    Id number,
    PostHistoryTypeId number,
    PostId number,
    RevisionGUID other,
    CreationDate time,
    UserId number,
    UserDisplayName text,
    Comment text,
    Text text,
    ContentLicense text
)

CREATE TABLE Tags (
    Id number,
    TagName text,
    Count number,
    ExcerptPostId number,
    WikiPostId number
)

CREATE TABLE ReviewTaskResults (
    Id number,
    ReviewTaskId number,
    ReviewTaskResultTypeId number,
    CreationDate time,
    RejectionReasonId number,
    Comment text
)

CREATE TABLE Posts (
    Id number,
    PostTypeId number,
    AcceptedAnswerId number,
    ParentId number,
    CreationDate time,
    DeletionDate time,
    Score number,
    ViewCount number,
    Body text,
    OwnerUserId number,
    OwnerDisplayName text,
    LastEditorUserId number,
    LastEditorDisplayName text,
    LastEditDate time,
    LastActivityDate time,
    Title text,
    Tags text,
    AnswerCount number,
    CommentCount number,
    FavoriteCount number,
    ClosedDate time,
    CommunityOwnedDate time,
    ContentLicense text
)

CREATE TABLE CloseAsOffTopicReasonTypes (
    Id number,
    IsUniversal boolean,
    InputTitle text,
    MarkdownInputGuidance text,
    MarkdownPostOwnerGuidance text,
    MarkdownPrivilegedUserGuidance text,
    MarkdownConcensusDescription text,
    CreationDate time,
    CreationModeratorId number,
    ApprovalDate time,
    ApprovalModeratorId number,
    DeactivationDate time,
    DeactivationModeratorId number
)

CREATE TABLE PostTags (
    PostId number,
    TagId number
)

CREATE TABLE PostHistoryTypes (
    Id number,
    Name text
)

CREATE TABLE SuggestedEdits (
    Id number,
    PostId number,
    CreationDate time,
    ApprovalDate time,
    RejectionDate time,
    OwnerUserId number,
    Comment text,
    Text text,
    Title text,
    Tags text,
    RevisionGUID other
)

CREATE TABLE Votes (
    Id number,
    PostId number,
    VoteTypeId number,
    UserId number,
    CreationDate time,
    BountyAmount number
)

CREATE TABLE Comments (
    Id number,
    PostId number,
    Score number,
    Text text,
    CreationDate time,
    UserDisplayName text,
    UserId number,
    ContentLicense text
)

CREATE TABLE PostNoticeTypes (
    Id number,
    ClassId number,
    Name text,
    Body text,
    IsHidden boolean,
    Predefined boolean,
    PostNoticeDurationId number
)

CREATE TABLE Badges (
    Id number,
    UserId number,
    Name text,
    Date time,
    Class number,
    TagBased boolean
)

CREATE TABLE FlagTypes (
    Id number,
    Name text,
    Description text
)

CREATE TABLE ReviewTaskResultTypes (
    Id number,
    Name text,
    Description text
)

CREATE TABLE Users (
    Id number,
    Reputation number,
    CreationDate time,
    DisplayName text,
    LastAccessDate time,
    WebsiteUrl text,
    Location text,
    AboutMe text,
    Views number,
    UpVotes number,
    DownVotes number,
    ProfileImageUrl text,
    EmailHash text,
    AccountId number
)

CREATE TABLE ReviewTaskStates (
    Id number,
    Name text,
    Description text
)

CREATE TABLE PostLinks (
    Id number,
    CreationDate time,
    PostId number,
    RelatedPostId number,
    LinkTypeId number
)

CREATE TABLE CloseReasonTypes (
    Id number,
    Name text,
    Description text
)

CREATE TABLE PostNotices (
    Id number,
    PostId number,
    PostNoticeTypeId number,
    CreationDate time,
    DeletionDate time,
    ExpiryDate time,
    Body text,
    OwnerUserId number,
    DeletionUserId number
)

CREATE TABLE PendingFlags (
    Id number,
    FlagTypeId number,
    PostId number,
    CreationDate time,
    CloseReasonTypeId number,
    CloseAsOffTopicReasonTypeId number,
    DuplicateOfQuestionId number,
    BelongsOnBaseHostAddress text
) ### Response: WITH ScoreByTag AS (SELECT pt.TagId, p.Score, ROW_NUMBER() OVER (PARTITION BY pt.TagId ORDER BY p.Score DESC) AS "rank" FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id) SELECT RANK() OVER (ORDER BY st.Score DESC) AS "rank", t.TagName, st.Score FROM ScoreByTag AS st INNER JOIN Tags AS t ON st.TagId = t.Id WHERE st.Rank = 1 ORDER BY st.Score DESC


Instruction: Show me mean rating by languages in a histogram, sort X from high to low order.

Input:
CREATE TABLE genre (
    g_name varchar2(20),
    rating varchar2(10),
    most_popular_in varchar2(50)
)

CREATE TABLE artist (
    artist_name varchar2(50),
    country varchar2(20),
    gender varchar2(20),
    preferred_genre varchar2(50)
)

CREATE TABLE song (
    song_name varchar2(50),
    artist_name varchar2(50),
    country varchar2(20),
    f_id number(10),
    genre_is varchar2(20),
    rating number(10),
    languages varchar2(20),
    releasedate Date,
    resolution number(10)
)

CREATE TABLE files (
    f_id number(10),
    artist_name varchar2(50),
    file_size varchar2(20),
    duration varchar2(20),
    formats varchar2(20)
)

Response: SELECT languages, AVG(rating) FROM song GROUP BY languages ORDER BY languages DESC

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: Show me mean rating by languages in a histogram, sort X from high to low order. ### Input: CREATE TABLE genre (
    g_name varchar2(20),
    rating varchar2(10),
    most_popular_in varchar2(50)
)

CREATE TABLE artist (
    artist_name varchar2(50),
    country varchar2(20),
    gender varchar2(20),
    preferred_genre varchar2(50)
)

CREATE TABLE song (
    song_name varchar2(50),
    artist_name varchar2(50),
    country varchar2(20),
    f_id number(10),
    genre_is varchar2(20),
    rating number(10),
    languages varchar2(20),
    releasedate Date,
    resolution number(10)
)

CREATE TABLE files (
    f_id number(10),
    artist_name varchar2(50),
    file_size varchar2(20),
    duration varchar2(20),
    formats varchar2(20)
) ### Response: SELECT languages, AVG(rating) FROM song GROUP BY languages ORDER BY languages DESC


Instruction: what's the score where record is 35 33

Input:
CREATE TABLE table_17347 (
    "#" real,
    "Date" text,
    "Visitor" text,
    "Score" text,
    "Home" text,
    "Leading scorer" text,
    "Attendance" text,
    "Record" text,
    "Streak" text
)

Response: SELECT "Score" FROM table_17347 WHERE "Record" = '35–33'

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: what's the score where record is 35 33 ### Input: CREATE TABLE table_17347 (
    "#" real,
    "Date" text,
    "Visitor" text,
    "Score" text,
    "Home" text,
    "Leading scorer" text,
    "Attendance" text,
    "Record" text,
    "Streak" text
) ### Response: SELECT "Score" FROM table_17347 WHERE "Record" = '35–33'


Instruction: What was the score of the game that put the team at 27-32?

Input:
CREATE TABLE table_name_51 (
    loss VARCHAR,
    record VARCHAR
)

Response: SELECT loss FROM table_name_51 WHERE record = "27-32"

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What was the score of the game that put the team at 27-32? ### Input: CREATE TABLE table_name_51 (
    loss VARCHAR,
    record VARCHAR
) ### Response: SELECT loss FROM table_name_51 WHERE record = "27-32"


Instruction: What was the To par for bill britton when he placed t7?

Input:
CREATE TABLE table_name_37 (
    to_par VARCHAR,
    place VARCHAR,
    player VARCHAR
)

Response: SELECT to_par FROM table_name_37 WHERE place = "t7" AND player = "bill britton"

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What was the To par for bill britton when he placed t7? ### Input: CREATE TABLE table_name_37 (
    to_par VARCHAR,
    place VARCHAR,
    player VARCHAR
) ### Response: SELECT to_par FROM table_name_37 WHERE place = "t7" AND player = "bill britton"


Instruction: what is the number of patients whose admission type is elective and procedure long title is laparoscopic lysis of peritoneal adhesions?

Input:
CREATE TABLE lab (
    subject_id text,
    hadm_id text,
    itemid text,
    charttime text,
    flag text,
    value_unit text,
    label text,
    fluid text
)

CREATE TABLE diagnoses (
    subject_id text,
    hadm_id text,
    icd9_code text,
    short_title text,
    long_title text
)

CREATE TABLE demographic (
    subject_id text,
    hadm_id text,
    name text,
    marital_status text,
    age text,
    dob text,
    gender text,
    language text,
    religion text,
    admission_type text,
    days_stay text,
    insurance text,
    ethnicity text,
    expire_flag text,
    admission_location text,
    discharge_location text,
    diagnosis text,
    dod text,
    dob_year text,
    dod_year text,
    admittime text,
    dischtime text,
    admityear text
)

CREATE TABLE procedures (
    subject_id text,
    hadm_id text,
    icd9_code text,
    short_title text,
    long_title text
)

CREATE TABLE prescriptions (
    subject_id text,
    hadm_id text,
    icustay_id text,
    drug_type text,
    drug text,
    formulary_drug_cd text,
    route text,
    drug_dose text
)

Response: SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND procedures.long_title = "Laparoscopic lysis of peritoneal adhesions"

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: what is the number of patients whose admission type is elective and procedure long title is laparoscopic lysis of peritoneal adhesions? ### Input: CREATE TABLE lab (
    subject_id text,
    hadm_id text,
    itemid text,
    charttime text,
    flag text,
    value_unit text,
    label text,
    fluid text
)

CREATE TABLE diagnoses (
    subject_id text,
    hadm_id text,
    icd9_code text,
    short_title text,
    long_title text
)

CREATE TABLE demographic (
    subject_id text,
    hadm_id text,
    name text,
    marital_status text,
    age text,
    dob text,
    gender text,
    language text,
    religion text,
    admission_type text,
    days_stay text,
    insurance text,
    ethnicity text,
    expire_flag text,
    admission_location text,
    discharge_location text,
    diagnosis text,
    dod text,
    dob_year text,
    dod_year text,
    admittime text,
    dischtime text,
    admityear text
)

CREATE TABLE procedures (
    subject_id text,
    hadm_id text,
    icd9_code text,
    short_title text,
    long_title text
)

CREATE TABLE prescriptions (
    subject_id text,
    hadm_id text,
    icustay_id text,
    drug_type text,
    drug text,
    formulary_drug_cd text,
    route text,
    drug_dose text
) ### Response: SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND procedures.long_title = "Laparoscopic lysis of peritoneal adhesions"


Instruction: What's the record that had an opponent of Krzysztof Soszynski and a time of 4:00?

Input:
CREATE TABLE table_name_64 (
    record VARCHAR,
    time VARCHAR,
    opponent VARCHAR
)

Response: SELECT record FROM table_name_64 WHERE time = "4:00" AND opponent = "krzysztof soszynski"

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What's the record that had an opponent of Krzysztof Soszynski and a time of 4:00? ### Input: CREATE TABLE table_name_64 (
    record VARCHAR,
    time VARCHAR,
    opponent VARCHAR
) ### Response: SELECT record FROM table_name_64 WHERE time = "4:00" AND opponent = "krzysztof soszynski"


Instruction: What's the status on 16/12/1995?

Input:
CREATE TABLE table_name_35 (
    status VARCHAR,
    date VARCHAR
)

Response: SELECT status FROM table_name_35 WHERE date = "16/12/1995"

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What's the status on 16/12/1995? ### Input: CREATE TABLE table_name_35 (
    status VARCHAR,
    date VARCHAR
) ### Response: SELECT status FROM table_name_35 WHERE date = "16/12/1995"


Instruction: What was the crowd size when the visiting team scored 23.18 (156)?

Input:
CREATE TABLE table_56036 (
    "Home team" text,
    "Home team score" text,
    "Away team" text,
    "Away team score" text,
    "Venue" text,
    "Crowd" real,
    "Date" text
)

Response: SELECT COUNT("Crowd") FROM table_56036 WHERE "Away team score" = '23.18 (156)'

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What was the crowd size when the visiting team scored 23.18 (156)? ### Input: CREATE TABLE table_56036 (
    "Home team" text,
    "Home team score" text,
    "Away team" text,
    "Away team score" text,
    "Venue" text,
    "Crowd" real,
    "Date" text
) ### Response: SELECT COUNT("Crowd") FROM table_56036 WHERE "Away team score" = '23.18 (156)'


Instruction: what is the highest frequency mhz with the call sign w292cu?

Input:
CREATE TABLE table_name_77 (
    frequency_mhz INTEGER,
    call_sign VARCHAR
)

Response: SELECT MAX(frequency_mhz) FROM table_name_77 WHERE call_sign = "w292cu"

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: what is the highest frequency mhz with the call sign w292cu? ### Input: CREATE TABLE table_name_77 (
    frequency_mhz INTEGER,
    call_sign VARCHAR
) ### Response: SELECT MAX(frequency_mhz) FROM table_name_77 WHERE call_sign = "w292cu"


Instruction: how many patients were prescribed 2 ml : metoclopramide hcl 5 mg/ml inj soln within 2 months since 2103 after being diagnosed with copd - no limitations?

Input:
CREATE TABLE vitalperiodic (
    vitalperiodicid number,
    patientunitstayid number,
    temperature number,
    sao2 number,
    heartrate number,
    respiration number,
    systemicsystolic number,
    systemicdiastolic number,
    systemicmean number,
    observationtime time
)

CREATE TABLE lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime time
)

CREATE TABLE medication (
    medicationid number,
    patientunitstayid number,
    drugname text,
    dosage text,
    routeadmin text,
    drugstarttime time,
    drugstoptime time
)

CREATE TABLE patient (
    uniquepid text,
    patienthealthsystemstayid number,
    patientunitstayid number,
    gender text,
    age text,
    ethnicity text,
    hospitalid number,
    wardid number,
    admissionheight number,
    admissionweight number,
    dischargeweight number,
    hospitaladmittime time,
    hospitaladmitsource text,
    unitadmittime time,
    unitdischargetime time,
    hospitaldischargetime time,
    hospitaldischargestatus text
)

CREATE TABLE diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

CREATE TABLE treatment (
    treatmentid number,
    patientunitstayid number,
    treatmentname text,
    treatmenttime time
)

CREATE TABLE cost (
    costid number,
    uniquepid text,
    patienthealthsystemstayid number,
    eventtype text,
    eventid number,
    chargetime time,
    cost number
)

CREATE TABLE allergy (
    allergyid number,
    patientunitstayid number,
    drugname text,
    allergyname text,
    allergytime time
)

CREATE TABLE microlab (
    microlabid number,
    patientunitstayid number,
    culturesite text,
    organism text,
    culturetakentime time
)

CREATE TABLE intakeoutput (
    intakeoutputid number,
    patientunitstayid number,
    cellpath text,
    celllabel text,
    cellvaluenumeric number,
    intakeoutputtime time
)

Response: SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'copd - no limitations' AND STRFTIME('%y', diagnosis.diagnosistime) >= '2103') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = '2 ml : metoclopramide hcl 5 mg/ml inj soln' AND STRFTIME('%y', medication.drugstarttime) >= '2103') AS t2 WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: how many patients were prescribed 2 ml : metoclopramide hcl 5 mg/ml inj soln within 2 months since 2103 after being diagnosed with copd - no limitations? ### Input: CREATE TABLE vitalperiodic (
    vitalperiodicid number,
    patientunitstayid number,
    temperature number,
    sao2 number,
    heartrate number,
    respiration number,
    systemicsystolic number,
    systemicdiastolic number,
    systemicmean number,
    observationtime time
)

CREATE TABLE lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime time
)

CREATE TABLE medication (
    medicationid number,
    patientunitstayid number,
    drugname text,
    dosage text,
    routeadmin text,
    drugstarttime time,
    drugstoptime time
)

CREATE TABLE patient (
    uniquepid text,
    patienthealthsystemstayid number,
    patientunitstayid number,
    gender text,
    age text,
    ethnicity text,
    hospitalid number,
    wardid number,
    admissionheight number,
    admissionweight number,
    dischargeweight number,
    hospitaladmittime time,
    hospitaladmitsource text,
    unitadmittime time,
    unitdischargetime time,
    hospitaldischargetime time,
    hospitaldischargestatus text
)

CREATE TABLE diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

CREATE TABLE treatment (
    treatmentid number,
    patientunitstayid number,
    treatmentname text,
    treatmenttime time
)

CREATE TABLE cost (
    costid number,
    uniquepid text,
    patienthealthsystemstayid number,
    eventtype text,
    eventid number,
    chargetime time,
    cost number
)

CREATE TABLE allergy (
    allergyid number,
    patientunitstayid number,
    drugname text,
    allergyname text,
    allergytime time
)

CREATE TABLE microlab (
    microlabid number,
    patientunitstayid number,
    culturesite text,
    organism text,
    culturetakentime time
)

CREATE TABLE intakeoutput (
    intakeoutputid number,
    patientunitstayid number,
    cellpath text,
    celllabel text,
    cellvaluenumeric number,
    intakeoutputtime time
) ### Response: SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'copd - no limitations' AND STRFTIME('%y', diagnosis.diagnosistime) >= '2103') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = '2 ml : metoclopramide hcl 5 mg/ml inj soln' AND STRFTIME('%y', medication.drugstarttime) >= '2103') AS t2 WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')


Instruction: What is the average high temperature for each day of week Plot them as bar chart, rank Y-axis in desc order.

Input:
CREATE TABLE station (
    id int,
    network_name text,
    services text,
    local_authority text
)

CREATE TABLE route (
    train_id int,
    station_id int
)

CREATE TABLE weekly_weather (
    station_id int,
    day_of_week text,
    high_temperature int,
    low_temperature int,
    precipitation real,
    wind_speed_mph int
)

CREATE TABLE train (
    id int,
    train_number int,
    name text,
    origin text,
    destination text,
    time text,
    interval text
)

Response: SELECT day_of_week, AVG(high_temperature) FROM weekly_weather GROUP BY day_of_week ORDER BY AVG(high_temperature) DESC

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What is the average high temperature for each day of week Plot them as bar chart, rank Y-axis in desc order. ### Input: CREATE TABLE station (
    id int,
    network_name text,
    services text,
    local_authority text
)

CREATE TABLE route (
    train_id int,
    station_id int
)

CREATE TABLE weekly_weather (
    station_id int,
    day_of_week text,
    high_temperature int,
    low_temperature int,
    precipitation real,
    wind_speed_mph int
)

CREATE TABLE train (
    id int,
    train_number int,
    name text,
    origin text,
    destination text,
    time text,
    interval text
) ### Response: SELECT day_of_week, AVG(high_temperature) FROM weekly_weather GROUP BY day_of_week ORDER BY AVG(high_temperature) DESC


Instruction: What was the lowest production code value in series #10?

Input:
CREATE TABLE table_name_14 (
    production_code INTEGER,
    series__number VARCHAR
)

Response: SELECT MIN(production_code) FROM table_name_14 WHERE series__number = 10

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What was the lowest production code value in series #10? ### Input: CREATE TABLE table_name_14 (
    production_code INTEGER,
    series__number VARCHAR
) ### Response: SELECT MIN(production_code) FROM table_name_14 WHERE series__number = 10


Instruction: What is the total of attendance with a Record of 5-9-0?

Input:
CREATE TABLE table_56683 (
    "Date" text,
    "Visitor" text,
    "Score" text,
    "Home" text,
    "Decision" text,
    "Attendance" real,
    "Record" text
)

Response: SELECT SUM("Attendance") FROM table_56683 WHERE "Record" = '5-9-0'

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What is the total of attendance with a Record of 5-9-0? ### Input: CREATE TABLE table_56683 (
    "Date" text,
    "Visitor" text,
    "Score" text,
    "Home" text,
    "Decision" text,
    "Attendance" real,
    "Record" text
) ### Response: SELECT SUM("Attendance") FROM table_56683 WHERE "Record" = '5-9-0'


Instruction: What is the low lap total for a grid larger than 16 and has a Time/Retired of + 3:27.3?

Input:
CREATE TABLE table_78184 (
    "Driver" text,
    "Constructor" text,
    "Laps" real,
    "Time/Retired" text,
    "Grid" real
)

Response: SELECT MIN("Laps") FROM table_78184 WHERE "Time/Retired" = '+ 3:27.3' AND "Grid" > '16'

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What is the low lap total for a grid larger than 16 and has a Time/Retired of + 3:27.3? ### Input: CREATE TABLE table_78184 (
    "Driver" text,
    "Constructor" text,
    "Laps" real,
    "Time/Retired" text,
    "Grid" real
) ### Response: SELECT MIN("Laps") FROM table_78184 WHERE "Time/Retired" = '+ 3:27.3' AND "Grid" > '16'


Instruction: which reps were only appointed by franklin pierce ?

Input:
CREATE TABLE table_203_778 (
    id number,
    "representative" text,
    "title" text,
    "presentation\nof credentials" text,
    "termination\nof mission" text,
    "appointed by" text
)

Response: SELECT "representative" FROM table_203_778 WHERE "appointed by" = 'franklin pierce'

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: which reps were only appointed by franklin pierce ? ### Input: CREATE TABLE table_203_778 (
    id number,
    "representative" text,
    "title" text,
    "presentation\nof credentials" text,
    "termination\nof mission" text,
    "appointed by" text
) ### Response: SELECT "representative" FROM table_203_778 WHERE "appointed by" = 'franklin pierce'


Instruction: Which Champion has a Coeff of 1.000?

Input:
CREATE TABLE table_52977 (
    "Season" text,
    "UEFA Season" text,
    "Coeff" text,
    "Ranking" real,
    "Champions" text,
    "Runner-up" text,
    "3rd place" text,
    "Cup winner" text,
    "Cup runner-up" text
)

Response: SELECT "Champions" FROM table_52977 WHERE "Coeff" = '1.000'

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: Which Champion has a Coeff of 1.000? ### Input: CREATE TABLE table_52977 (
    "Season" text,
    "UEFA Season" text,
    "Coeff" text,
    "Ranking" real,
    "Champions" text,
    "Runner-up" text,
    "3rd place" text,
    "Cup winner" text,
    "Cup runner-up" text
) ### Response: SELECT "Champions" FROM table_52977 WHERE "Coeff" = '1.000'


Instruction: What is the 2nd leg in match with team 2 of Teram?

Input:
CREATE TABLE table_62868 (
    "Team 1" text,
    "Agg." text,
    "Team 2" text,
    "1st leg" text,
    "2nd leg" text
)

Response: SELECT "2nd leg" FROM table_62868 WHERE "Team 2" = 'teram'

Below are sql tables schemas paired with instruction that describes a task. Using valid SQLite, write a response that appropriately completes the request for the provided tables. ### Instruction: What is the 2nd leg in match with team 2 of Teram? ### Input: CREATE TABLE table_62868 (
    "Team 1" text,
    "Agg." text,
    "Team 2" text,
    "1st leg" text,
    "2nd leg" text
) ### Response: SELECT "2nd leg" FROM table_62868 WHERE "Team 2" = 'teram'