ebmdatalab / prescribing-queries

Documentation about common queries against the prescribing dataset
GNU General Public License v3.0
3 stars 3 forks source link

LARCs in Nottinghamshire #63

Closed alexwalkerepi closed 6 years ago

alexwalkerepi commented 6 years ago

BNF codes: 0703022POBC 0703022POBB 0703022POBBAAAA 0703023LOBB 0703023LOBBAAAA 21040000266 21040000248 21040000285 0703022MOBB 0703022MOBD

Time Period (earliest date August 2010) | Jan 2017 to Dec 2017 (inclusive) Grouped monthly/yearly: | Monthly CCG/GP Practice(s) of Interest: 02Q 04E 04H 04L 04M 04N 04K Grouped by GP Practice or CCG? | By Practice Include non-standard GP Practices? | No Include Actual Cost? | No Other Information | Please include GP code in outputs. I am emailing details on an excel sheet to EBM data email address. When do you need the data by? | Ideally w/c 26 February

alexwalkerepi commented 6 years ago
SELECT
  FORMAT_DATETIME('%Y-%m',
    DATETIME(presc.month)) AS month,
  practice,
  pct AS ccg,
  bnf_code,
  bnf_name,
  items,
  quantity,
  net_cost
FROM
  ebmdatalab.hscic.normalised_prescribing_standard AS presc
LEFT JOIN
  ebmdatalab.hscic.practices AS pract
ON
  presc.practice=pract.code
  AND pract.setting=4
WHERE
  (bnf_code LIKE "0703022P0BC%"
    OR bnf_code LIKE "0703022P0BB%"
    OR bnf_code LIKE "0703023L0BB%"
    OR bnf_code LIKE "21040000266%"
    OR bnf_code LIKE "21040000248%"
    OR bnf_code LIKE "21040000285%"
    OR bnf_code LIKE "0703022M0BB%"
    OR bnf_code LIKE "0703022M0BD%")
  AND month >= '2017-01-01'
  AND month <= '2017-12-01'
  AND (pct = "02Q"
    OR pct = "04E"
    OR pct = "04H"
    OR pct = "04L"
    OR pct = "04M"
    OR pct = "04N"
    OR pct = "04K")
ORDER BY
  bnf_code,
  practice,
  month