input
stringclasses 1
value | instruction
stringlengths 54
195
| output
stringlengths 281
2.05k
|
---|---|---|
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is Kyprolis's claims volume in the last 3 months? |
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day); |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is Kyprolis's claims volume in the last 3 months for MM indication? |
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day); |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which brand had the highest claims in MM indication in last 3 months? |
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Drug_Name
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which brand had the highest claims in NY state in MM indication in last 3 months? |
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Patient_State = 'NY'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Drug_Name
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Identify the state where Kyprolis had the most prescriptions for MM indications? Ignore blanks for state |
SELECT Patient_State, COUNT(distinct(Claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Patient_State NOT LIKE 'None'
AND Patient_State NOT LIKE ''
GROUP BY Patient_State
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What was the market share of the top 5 drugs prescribed for MM indication over the last 3 months? |
WITH top_5_drugs AS (
SELECT Drug_Name, count (distinct(claim_id)) as prescription_count
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Drug_Name
order by prescription_count desc
limit 5
),
total_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) AS total_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
)
SELECT
top_5_drugs.Drug_Name,
ROUND(100.0 * top_5_drugs.prescription_count / total_prescriptions.total_prescriptions, 2) as market_share
FROM top_5_drugs, total_prescriptions; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Give me the market share by drug for the top 5 drugs for MM indication over the last 3 months |
WITH
top_5_drugs AS (
SELECT Drug_Name, count (distinct(claim_id)) as prescription_count
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Drug_Name
order by prescription_count desc
limit 5
),
total_claims AS (
SELECT COUNT(distinct(claim_ID)) AS total_claims
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
)
SELECT
top_5_drugs.Drug_Name,
ROUND(100.0 * top_5_drugs.prescription_count / total_claims.total_claims, 2) as market_share
FROM top_5_drugs, total_claims; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What was the market share for Kyprolis for years 2021 and 2022 for MM indication? |
WITH
kyprolis_2021 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date('2021-01-01')
AND Prescription_Fill_Year_Month <= date('2021-12-31')
AND indication like '%MM%'
),
kyprolis_2022 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date('2022-01-01')
AND Prescription_Fill_Year_Month <= date('2022-12-31')
AND indication like '%MM%'
),
total_2021 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Prescription_Fill_Year_Month >= date('2021-01-01')
AND Prescription_Fill_Year_Month <= date('2021-12-31')
AND indication like '%MM%'
),
total_2022 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Prescription_Fill_Year_Month >= date('2022-01-01')
AND Prescription_Fill_Year_Month <= date('2022-12-31')
AND indication like '%MM%'
)
SELECT
ROUND(100.0 * kyprolis_2021.num_prescriptions / total_2021.num_prescriptions, 2) AS kyprolis_2021_market_share,
ROUND(100.0 * kyprolis_2022.num_prescriptions / total_2022.num_prescriptions, 2) AS kyprolis_2022_market_share
FROM kyprolis_2021, kyprolis_2022, total_2021, total_2022; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What's the most prescribed brand for MM indication? What is it's market share? |
WITH num AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS num_data
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%MM%'
AND Drug_Name IN (SELECT Drug_Name
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%MM%'
GROUP BY Drug_Name
ORDER BY COUNT(DISTINCT(Claim_ID)) DESC
LIMIT 1)
),
den AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%MM%'
)
SELECT ROUND(100.0 * num_data / den_data, 2) AS market_share
FROM num, den; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Over the past 3 months, which state in the US has seen a higher number of claims for Kyprolis in the MM indication compared to its competitors? |
WITH kyprolis_claims AS (
SELECT Patient_State, COUNT(distinct(claim_ID)) AS num_claims
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Patient_State
),
competitor_claims AS (
SELECT Patient_State, COUNT(distinct(claim_ID)) AS num_claims
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name not like '%KYPROLIS%'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Patient_State
)
SELECT kyprolis_claims.Patient_State
FROM kyprolis_claims, competitor_claims
WHERE kyprolis_claims.num_claims > competitor_claims.num_claims; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the relative growth of Kyprolis in last 3 months compared to previous year? |
WITH
numerator AS (
select count(Distinct(claim_ID)) as total_claims from "symphony-data"."test_performance_v3" where Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '3' month) and Drug_Name like '%KYPROLIS%'
),
denominator AS(
select count(distinct(claim_ID)) as total_claims from "symphony-data"."test_performance_v3" where Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year - interval '3' month) and Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year) and Drug_Name like '%KYPROLIS%'
)
SELECT (cast(numerator.total_claims as double) / (denominator.total_claims)-1)*100 as relative_growth from numerator, denominator; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | How did Kyprolis prescriptions for MM indication grow for 2021 vs 2020? |
WITH
kyprolis_prescriptions_2021 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
AND Prescription_Fill_Year_Month < date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3"))
),
kyprolis_prescriptions_2020 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '2' year)
AND Prescription_Fill_Year_Month < date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
)
SELECT (cast(kyprolis_prescriptions_2021.num_prescriptions as double) / (kyprolis_prescriptions_2020.num_prescriptions)-1)*100 as growth from kyprolis_prescriptions_2021, kyprolis_prescriptions_2020; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Calculate evolution index for Kyprolis for MM indication for the last 3 months versus same time period last year |
WITH
kyprolis_prescriptions_current AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '3' month)
),
kyprolis_prescriptions_previous AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year - interval '3' month)
AND Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
),
mm_prescriptions_current AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '3' month)
),
mm_prescriptions_previous AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year - interval '3' month)
AND Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
)
SELECT
ROUND(((1 + (cast(kyprolis_prescriptions_current.num_prescriptions as double) / kyprolis_prescriptions_previous.num_prescriptions - 1)) / (1 + (cast(mm_prescriptions_current.num_prescriptions as double) / mm_prescriptions_previous.num_prescriptions - 1))) ,2) as evolution_index |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | In which state has Kyprolis presciption count grown the most over the last 3 months compared to the same time period last year? |
WITH
numerator AS (
SELECT Patient_State, COUNT(distinct(claim_ID)) as total_claims
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '3' month)
GROUP BY Patient_State
),
denominator AS(
SELECT Patient_State, COUNT(distinct(claim_ID)) as total_claims
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year - interval '3' month)
AND Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
GROUP BY Patient_State
)
SELECT numerator.Patient_State, (cast(numerator.total_claims as double) / (denominator.total_claims)-1)*100 as growth_percentage
FROM numerator, denominator
ORDER BY growth_percentage DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | For patients over 60 prescribed drugs for MM indication, what percentage of those prescriptions were for Kyprolis? |
WITH
total_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) AS total_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND patient_age >= 60
),
kyprolis_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) AS kyprolis_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND patient_age >= 60
AND Drug_Name like '%KYPROLIS%'
)
SELECT ROUND(100.0 * kyprolis_prescriptions.kyprolis_prescriptions / total_prescriptions.total_prescriptions, 2) as kyprolis_percentage
FROM total_prescriptions, kyprolis_prescriptions; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the market share of Kyprolis in MM indication for patients above 60 years? |
WITH num AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS num_data
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name LIKE '%KYPROLIS%'
AND indication LIKE '%MM%'
AND patient_age >= 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
),
den AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%MM%'
AND patient_age >= 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
)
SELECT ROUND(100.0 * num_data / den_data, 2) AS market_share
FROM num, den; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the market share of Kyprolis in MM indication for female/male patients over the last 6 months? |
WITH num AS
(
SELECT COUNT(DISTINCT(Claim_ID)) AS num_data
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name LIKE '%KYPROLIS%'
AND indication LIKE '%MM%'
AND Patient_Gender IN ('Male', 'Female')
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '180' day)
),
den AS
(
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%MM%'
AND Patient_Gender IN ('Male', 'Female')
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '180' day)
)
SELECT ROUND(100.0 * num_data / den_data, 2) AS market_share
FROM num, den; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which drug had highest claims for patients above 60 in MM indication over the last 1 year? |
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND patient_age > 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
GROUP BY Drug_Name
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which state in the US had the highest number of claims in the MM indication for patients over the age of 60 over the last 3 months? Exclude None and blank values in state column |
SELECT Patient_State, COUNT(distinct(Claim_ID)) as num_claims
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Patient_State NOT IN ('None', '')
AND patient_age > 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Patient_State
ORDER BY num_claims DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the most common payer type for Kyprolis in last 3 months? |
SELECT plan_type_description, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
AND plan_type_description NOT IN ('NONE', '')
GROUP BY plan_type_description
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the avg. out of pocket pay for Kyprolis in NY state in last 3 months? |
SELECT AVG(Total_Patient_Responsibility) as avg_patient_pay
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Patient_State = 'NY'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day); |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Could you provide a ranking of all the brands in the MM indication based on their share of commercial payers over the last 3 months? |
WITH
commercial_payers AS (
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE plan_type_description = 'COMMERCIAL'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Drug_Name
),
total_payers AS (
SELECT COUNT(distinct(claim_ID)) as total_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
)
SELECT Drug_Name, ROUND(100.0 * num_prescriptions / total_prescriptions, 2) as share_of_commercial_payers
FROM commercial_payers, total_payers
ORDER BY share_of_commercial_payers DESC; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Based on the average out-of-pocket expenses for patients over 60 years old in the MM indication over the last 6 months, could you please give me the 5 drugs with lowest out-of-pocket expenses? |
WITH avg_patient_pay AS (
SELECT Drug_Name, AVG(Total_Patient_Responsibility) as avg_patient_pay
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND patient_age >= 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Drug_Name
)
SELECT Drug_Name, avg_patient_pay
FROM avg_patient_pay
ORDER BY avg_patient_pay ASC
LIMIT 5; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is Kyprolis's claims volume in the last 3 months for patient above 60 and male? | SELECT COUNT(distinct(claim_ID)) as num_claims
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
AND patient_age > 60
AND Patient_Gender = 'Male';
|
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the most common payer type for Kyprolis in last 3 months for the indication mm? | SELECT plan_type_description, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND plan_type_description not like 'NONE'
AND plan_type_description not like ''
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY plan_type_description
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the market share of Kyprolis in MM indication for female/male patients over the last 6 months for the plan type Commercial? |
WITH num AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS num_data
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Patient_Gender IN ('Female', 'Male')
AND plan_type_description = 'COMMERCIAL'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '180' day)
),
den AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication IN (SELECT DISTINCT(indication) FROM "symphony-data"."test_performance_v3"
WHERE indication NOT LIKE 'No Indication'
AND indication NOT LIKE 'Unknown_Flag'
AND indication LIKE '%MM%')
AND Patient_Gender IN ('Female', 'Male')
AND plan_type_description = 'COMMERCIAL'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '180' day)
)
SELECT ROUND(100.0 * num_data / den_data, 2) AS market_share
FROM num, den; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the most common payer type for Kyprolis in last 3 months in ny state? |
WITH kyprolis_prescriptions AS (
SELECT plan_type_description, COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
AND Patient_State = 'NY'
GROUP BY plan_type_description
)
SELECT plan_type_description, num_prescriptions
FROM kyprolis_prescriptions
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | How did Kyprolis prescriptions for MM indication for the patient less than 45 years grow for 2021 vs 2020? |
WITH
kyprolis_prescriptions_2021 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND patient_age < 45
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
AND Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3"))
),
kyprolis_prescriptions_2020 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND patient_age < 45
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '2' year)
AND Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
)
SELECT (cast(kyprolis_prescriptions_2021.num_prescriptions as double) / (kyprolis_prescriptions_2020.num_prescriptions)-1)*100 as growth from kyprolis_prescriptions_2021, kyprolis_prescriptions_2020; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the market share of Kyprolis in MM indication for female patients above 45 years? |
WITH num AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS num_data
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Patient_Gender = 'Female'
AND patient_age > 45
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
),
den AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%MM%'
AND Patient_Gender = 'Female'
AND patient_age > 45
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
)
SELECT ROUND(100.0 * num_data / den_data, 2) AS market_share
FROM num, den; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the claims volume of Kyprolis in the MM indication in the past 6 months? |
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%MM%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month); |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the claims volume of Kyprolis in the cml indication in the past 6 months specifically for (cml)? |
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND indication like '%Multiple Myeloma%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month); |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which brand had the highest claims volume in the cml indication in the past 6 months? |
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Drug_Name
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which brand had the highest claims volume in the cml indication in the state of New York (NY) in the past 6 months? | "
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_claims
FROM ""symphony-data"".""test_performance_v3""
WHERE indication like '%ITP%'
AND Patient_State = 'NY'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from ""symphony-data"".""test_performance_v3"") - interval '6' month)
GROUP BY Drug_Name
ORDER BY num_claims DESC
LIMIT 1;" |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | In which state did Kyprolis have the highest number of prescriptions for the cml indication? | "
SELECT Patient_State, COUNT(distinct(Claim_ID)) as num_prescriptions
FROM ""symphony-data"".""test_performance_v3""
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%ITP%'
AND Patient_State NOT LIKE 'None'
AND Patient_State NOT LIKE ''
GROUP BY Patient_State
ORDER BY num_prescriptions DESC
LIMIT 1;" |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What was the market share of the top 5 drugs prescribed for the cml indication over the past 6 months? | "
WITH
top_5_drugs AS (
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_prescriptions
FROM ""symphony-data"".""test_performance_v3""
WHERE indication like '%ITP%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from ""symphony-data"".""test_performance_v3"") - interval '6' month)
GROUP BY Drug_Name
order by num_prescriptions desc
limit 5
),
total_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) as total_prescriptions
FROM ""symphony-data"".""test_performance_v3""
WHERE indication like '%ITP%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from ""symphony-data"".""test_performance_v3"") - interval '6' month)
)
SELECT
top_5_drugs.Drug_Name,
ROUND(100.0 * top_5_drugs.num_prescriptions / total_prescriptions.total_prescriptions, 2) as market_share
FROM top_5_drugs, total_prescriptions;" |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Can you provide the market share by drug for the top 5 drugs prescribed for the cml indication over the past 6 months? |
WITH top_5_drugs AS (
SELECT Drug_Name, count (distinct(claim_id)) as prescription_count
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Drug_Name
order by prescription_count desc
limit 5
),
total_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) AS total_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
)
SELECT
top_5_drugs.Drug_Name,
ROUND(100.0 * top_5_drugs.prescription_count / total_prescriptions.total_prescriptions, 2) as market_share
FROM top_5_drugs, total_prescriptions; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What was the market share of Kyprolis for the cml indication in the years 2020 and 2022? |
WITH
kyprolis_2020 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date '2020-01-01'
AND Prescription_Fill_Year_Month <= date '2020-12-31'
),
kyprolis_2022 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date '2022-01-01'
AND Prescription_Fill_Year_Month <= date '2022-12-31'
),
total_2020 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date '2020-01-01'
AND Prescription_Fill_Year_Month <= date '2020-12-31'
),
total_2022 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date '2022-01-01'
AND Prescription_Fill_Year_Month <= date '2022-12-31'
)
SELECT
ROUND(100.0 * kyprolis_2020.num_prescriptions / total_2020.num_prescriptions, 2) AS kyprolis_2020_market_share,
ROUND(100.0 * kyprolis_2022.num_prescriptions / total_2022.num_prescriptions, 2) AS kyprolis_2022_market_share
FROM kyprolis_2020, kyprolis_20 |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which brand was the most prescribed for the cml indication, and what was its market share? |
WITH den AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
),
brand_data AS (
SELECT Drug_Name, COUNT(DISTINCT(Claim_ID)) AS brand_data
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
GROUP BY Drug_Name
ORDER BY brand_data DESC
LIMIT 1
)
SELECT Drug_Name, ROUND(100.0 * brand_data / den_data, 2) AS market_share
FROM den, brand_data; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Over the past 6 months, which state in the US had a higher number of claims for Kyprolis in the cml indication compared to its competitors? |
WITH kyprolis_claims AS (
SELECT COUNT(distinct(claim_ID)) AS num_claims, Patient_State
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '180' day)
GROUP BY Patient_State
),
competitor_claims AS (
SELECT COUNT(distinct(claim_ID)) AS num_claims, Patient_State
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name not like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '180' day)
GROUP BY Patient_State
)
SELECT kyprolis_claims.Patient_State
FROM kyprolis_claims, competitor_claims
WHERE kyprolis_claims.num_claims > competitor_claims.num_claims; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the relative growth of Kyprolis in the past 6 months compared to the previous year? |
WITH
numerator AS (
select count(Distinct(claim_ID)) as total_claims from "symphony-data"."test_performance_v3" where Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month) and Drug_Name like '%KYPROLIS%'
),
denominator AS(
select count(distinct(claim_ID)) as total_claims from "symphony-data"."test_performance_v3" where Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year - interval '6' month) and Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year) and Drug_Name like '%KYPROLIS%'
)
SELECT (cast(numerator.total_claims as double) / (denominator.total_claims)-1)*100 as relative_growth from numerator, denominator; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | How did Kyprolis prescriptions for the cml indication grow from 2020 to 2022? |
WITH
kyprolis_prescriptions_2020 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date('2020-01-01')
AND Prescription_Fill_Year_Month <= date('2020-12-31')
),
kyprolis_prescriptions_2022 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date('2022-01-01')
AND Prescription_Fill_Year_Month <= date('2022-12-31')
)
SELECT (cast(kyprolis_prescriptions_2022.num_prescriptions as double) / (kyprolis_prescriptions_2020.num_prescriptions)-1)*100 as growth from kyprolis_prescriptions_2020, kyprolis_prescriptions_2022; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Calculate the evolution index for Kyprolis for the cml indication in the last 6 months compared to the same time period last year. |
WITH
kyprolis_prescriptions_current AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
),
kyprolis_prescriptions_previous AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year - interval '6' month)
AND Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
),
cml_prescriptions_current AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
),
cml_prescriptions_previous AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year - interval '6' month)
AND Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
)
SELECT (cast(kyprolis_prescriptions_current.num_prescriptions as double) / (kyprolis_prescriptions_previous.num_prescriptions)-1)/
(cast(cml_prescriptions_current.num_prescriptions as double) / (cml_prescriptions_previous.num_prescriptions)-1) as evolution_index
FROM kyprolis_prescriptions_current, kyprolis_prescriptions_previous, cml_prescriptions_current, cml_prescriptions_previous; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | In which state did Kyprolis prescription count grow the most in the past 6 months compared to the same time period last year? |
WITH
kyprolis_prescriptions_current_year AS (
SELECT Patient_State, COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Patient_State
),
kyprolis_prescriptions_previous_year AS (
SELECT Patient_State, COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year - interval '6' month)
AND Prescription_Fill_Year_Month <= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
GROUP BY Patient_State
)
SELECT
kyprolis_prescriptions_current_year.Patient_State,
(cast(kyprolis_prescriptions_current_year.num_prescriptions as double) / (kyprolis_prescriptions_previous_year.num_prescriptions)-1)*100 as growth
FROM kyprolis_prescriptions_current_year, kyprolis_prescriptions_previous_year
WHERE kyprolis_prescriptions_current_year.Patient_State = kyprolis_prescriptions_previous_year.Patient_State
ORDER BY growth DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | For patients over 60 who were prescribed drugs for the cml indication, what percentage of those prescriptions were for Kyprolis? |
WITH cml_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND patient_age >= 60
),
kyprolis_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND patient_age >= 60
)
SELECT
ROUND(100.0 * kyprolis_prescriptions.num_prescriptions / cml_prescriptions.num_prescriptions, 2) as kyprolis_percentage
FROM cml_prescriptions, kyprolis_prescriptions; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the market share of Kyprolis in the cml indication for patients above 60 years old? |
WITH num AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS num_data
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name LIKE '%KYPROLIS%'
AND indication LIKE '%CML%'
AND patient_age >= 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
),
den AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%CML%'
AND patient_age >= 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
)
SELECT ROUND(100.0 * num_data / den_data, 2) AS market_share
FROM num, den; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which drug had the highest claims for patients above 60 in the cml indication over the past year? |
WITH cml_claims AS (
SELECT Drug_Name, COUNT(distinct(claim_ID)) AS num_claims
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND patient_age > 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '1' year)
GROUP BY Drug_Name
)
SELECT Drug_Name, num_claims
FROM cml_claims
ORDER BY num_claims DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which state in the US had the highest number of claims in the cml indication for patients over the age of 60 in the past 6 months? (Exclude "None" and blank values in the state column) |
SELECT Patient_State, COUNT(distinct(Claim_ID)) as num_claims
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND patient_age > 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
AND Patient_State NOT IN ('None', '')
GROUP BY Patient_State
ORDER BY num_claims DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the most common payer type for Kyprolis in the past 6 months? |
WITH kyprolis_prescriptions AS (
SELECT plan_type_description, COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
AND plan_type_description NOT IN ('NONE', '')
GROUP BY plan_type_description
)
SELECT plan_type_description, num_prescriptions
FROM kyprolis_prescriptions
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the average out-of-pocket payment for Kyprolis in the state of New York (NY) in the past 6 months? |
SELECT AVG(Total_Patient_Responsibility) as avg_patient_pay
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Patient_State = 'NY'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month); |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Based on the average out-of-pocket expenses for patients over 60 years old in the cml indication over the past 6 months, can you please provide the 5 drugs with the lowest out-of-pocket expenses? |
WITH cml_prescriptions AS (
SELECT Drug_Name, AVG(Total_Patient_Responsibility) as avg_patient_pay
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND patient_age >= 60
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Drug_Name
)
SELECT Drug_Name, avg_patient_pay
FROM cml_prescriptions
ORDER BY avg_patient_pay ASC
LIMIT 5; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the claims volume of Kyprolis in the past 6 months for patients above 60 and male? |
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
AND patient_age > 60
AND Patient_Gender = 'Male'; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the most common payer type for Kyprolis in the past 6 months for the cml indication? |
WITH kyprolis_prescriptions AS (
SELECT plan_type_description, COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY plan_type_description
)
SELECT plan_type_description, num_prescriptions
FROM kyprolis_prescriptions
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the market share of Kyprolis in the cml indication for female and male patients over the past 6 months for the plan type Commercial? |
WITH num AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS num_data
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND Patient_Gender IN ('Male', 'Female')
AND plan_type_description = 'COMMERCIAL'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '180' day)
),
den AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Patient_Gender IN ('Male', 'Female')
AND plan_type_description = 'COMMERCIAL'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '180' day)
)
SELECT ROUND(100.0 * num_data / den_data, 2) AS market_share
FROM num, den; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the most common payer type for Kyprolis in the past 6 months in the state of New York (NY)? |
SELECT plan_type_description, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
AND Patient_State = 'NY'
AND plan_type_description NOT IN ('NONE', '')
GROUP BY plan_type_description
ORDER BY num_prescriptions DESC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | How did Kyprolis prescriptions for the cml indication for patients less than 45 years old grow from 2020 to 2022? |
WITH kyprolis_prescriptions_2020 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND patient_age < 45
AND Prescription_Fill_Year_Month >= date('2020-01-01')
AND Prescription_Fill_Year_Month < date('2021-01-01')
),
kyprolis_prescriptions_2022 AS (
SELECT COUNT(distinct(claim_ID)) AS num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name like '%KYPROLIS%'
AND indication like '%CML%'
AND patient_age < 45
AND Prescription_Fill_Year_Month >= date('2022-01-01')
AND Prescription_Fill_Year_Month < date('2023-01-01')
)
SELECT (cast(kyprolis_prescriptions_2022.num_prescriptions as double) / (kyprolis_prescriptions_2020.num_prescriptions)-1)*100 as growth from kyprolis_prescriptions_2020, kyprolis_prescriptions_2022; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What is the market share of Kyprolis in the cml indication for female patients above 45 years old? |
WITH num AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS num_data
FROM "symphony-data"."test_performance_v3"
WHERE Drug_Name LIKE '%KYPROLIS%'
AND indication LIKE '%CML%'
AND Patient_Gender = 'Female'
AND patient_age > 45
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
),
den AS (
SELECT COUNT(DISTINCT(Claim_ID)) AS den_data
FROM "symphony-data"."test_performance_v3"
WHERE indication LIKE '%CML%'
AND Patient_Gender = 'Female'
AND patient_age > 45
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '90' day)
)
SELECT ROUND(100.0 * num_data / den_data, 2) AS market_share
FROM num, den; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which brand had the lowest claims volume in the cml indication in the past 6 months? |
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Drug_Name
ORDER BY num_prescriptions ASC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | Which brand had the least claims volume in the cml indication in the state of New York (NY) in the past 6 months? |
SELECT Drug_Name, COUNT(distinct(claim_ID)) as num_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Patient_State = 'NY'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Drug_Name
ORDER BY num_prescriptions ASC
LIMIT 1; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What was the market share of the bottom 5 drugs prescribed for the cml indication over the past 6 months? | with
bottom_5_drugs AS (
SELECT Drug_Name, count (distinct(claim_id)) as prescription_count
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Drug_Name
order by prescription_count asc
limit 5
),
total_cml_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) AS total_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
)
SELECT
bottom_5_drugs.Drug_Name,
ROUND(100.0 * bottom_5_drugs.prescription_count / total_cml_prescriptions.total_prescriptions, 2) as market_share
FROM bottom_5_drugs, total_cml_prescriptions; |
Hi! I need your help in generating an MySQL/ansi sql query.You are sql query generator all you should return is only query I am going to give you the schema associated with a database.
Name of the table is ""test_performance_v3"".
Schema
Field Name | Field Type | Data Definition
NPI | varchar | 10 digit HCP identifier (Exclude blank and invalid NPIs from any queries)
Claim_ID | varchar | Unique claim identifier
Patient_ID | varchar | Unique patient identifier
Patient_Gender | varchar(8) | Patient Gender (Exclude ""Unknown"" and blank values from any queries)
Patient_State | varchar | State in which prescription was filled (Exclude ""None"" and blank values from any queries)
Region | varchar(9) | Region info of state
plan_type_description | varchar | Payor type (COMMERCIAL, MEDICARE, MEDICAID, etc.) in capital letters. (Exclude ""NONE"" and blank values from any queries)
Plan_Name | varchar | Specific payor name
Drug_name | varchar | Brand or Drug name
Prescribed_Drug_Indication | varchar(2922) | Drug indication (based on prescribed drug)
Prescription_Fill_Year_Month | date | Date when prescription was filled
quantity | double | total quantity of drugs prescribed in each prescription
Total_Patient_Responsibility | double | Out of Pocket expense borne by patient
Total_Payer_Responsibility | double | Expense borne by payor
patient_age | integer | numeric age of patient in years
indication | string | Indications for given patient
Unknown_Flag | varchar(3) | If no disease detected, this would be Yes | What was the market share of the first 5 drugs prescribed for the cml indication over the past 6 months? |
WITH
top_5_drugs AS (
SELECT Drug_Name, count (distinct(claim_id)) as prescription_count
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
GROUP BY Drug_Name
order by prescription_count desc
limit 5
),
total_prescriptions AS (
SELECT COUNT(distinct(claim_ID)) AS total_prescriptions
FROM "symphony-data"."test_performance_v3"
WHERE indication like '%CML%'
AND Prescription_Fill_Year_Month >= date((select max(Prescription_Fill_Year_Month)
from "symphony-data"."test_performance_v3") - interval '6' month)
)
SELECT
top_5_drugs.Drug_Name,
ROUND(100.0 * top_5_drugs.prescription_count / total_prescriptions.total_prescriptions, 2) as market_share
FROM top_5_drugs, total_prescriptions; |
No dataset card yet
- Downloads last month
- 11