SHARE
TWEET

Untitled

a guest Aug 25th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE VIEW TerapieTarget AS
  2. SELECT  T1.Patologia, T1.Farmaco, COUNT(*) AS NumTerapieOk
  3. FROM    terapia T1
  4.         INNER JOIN
  5.         farmaco F1 ON T1.Farmaco = F1.NomeCommerciale
  6. WHERE   DATEDIFF(T1.DataFineTerapia, T1.DataInizioTerapia) * T1.Posologia <= F1.Pezzi
  7. GROUP BY T1.Patologia, T1.Farmaco;
  8.  
  9. CREATE OR REPLACE VIEW TerapieTot AS
  10. SELECT  T1.Patologia, T1.Farmaco, COUNT(*) AS NumTerapieTot
  11. FROM    terapia T1
  12.         INNER JOIN
  13.         farmaco F1 ON T1.Farmaco = F1.NomeCommerciale
  14. GROUP BY T1.Patologia, T1.Farmaco;
  15.  
  16. CREATE OR REPLACE VIEW PatologiaNumFarmaci AS
  17. SELECT  TT.Patologia, COUNT(DISTINCT TT.Farmaco) AS NumeroFarmaciPatologia
  18. FROM    TerapieTarget TT
  19.         INNER JOIN
  20.         TerapieTot TOT USING(Patologia,Farmaco)
  21. WHERE   TT.NumTerapieOk / TOT.NumTerapieTot >= 0.65
  22. GROUP BY TT.Patologia;
  23.  
  24. CREATE OR REPLACE VIEW FarmaciTot AS
  25. SELECT  I.Patologia, COUNT(DISTINCT I.Farmaco) AS NumFarmaci
  26. FROM    indicazione I
  27. GROUP BY I.Patologia;
  28.  
  29. SELECT  PF.Patologia
  30. FROM    PatologiaNumFarmaci PF
  31.         NATURAL JOIN
  32.         FarmaciTot FT
  33. WHERE   PF.NumeroFarmaciPatologia = FT.NumFarmaci
  34. GROUP BY PF.Patologia;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top