daily pastebin goal
26%
SHARE
TWEET

Consultas [3]

LightProgrammer000 Nov 25th, 2018 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT SUM(presc.Prescricoes_Dia)
  2. FROM
  3. (
  4.     SELECT
  5.         --concat( COALESCE( NULL, count(*), 0 , null) , ' / dia') AS Prescrições_Dia,
  6.         COALESCE( NULL, COUNT(*), 0 , NULL) AS Prescricoes_Dia,
  7.         se.NM_SETOR AS Setor,
  8.         pm.DT_PRE_MED AS Data_Prescrição
  9.     FROM
  10.         PRE_MED pm
  11.         INNER JOIN SETOR se ON se.CD_SETOR = pm.CD_SETOR
  12.     GROUP BY
  13.         se.NM_SETOR,
  14.         pm.DT_PRE_MED
  15.     ORDER BY
  16.         pm.DT_PRE_MED ASC
  17.     )
  18.     presc
  19. ;
  20.  
  21. SELECT SUM(presc.Prescricoes_Dia)
  22. FROM (
  23. SELECT
  24.     CONCAT( COALESCE( NULL, COUNT(*), 0 , NULL) , '') AS Prescricoes_Dia,
  25.     -- COALESCE( NULL, count(*), 0 , null) AS Prescricoes_Dia,
  26.     se.NM_SETOR AS Setor,
  27.     pm.DT_PRE_MED AS Data_Prescrição
  28. FROM
  29.     PRE_MED pm
  30.     INNER JOIN SETOR se ON se.CD_SETOR = pm.CD_SETOR
  31. GROUP BY
  32.     se.NM_SETOR,
  33.     pm.DT_PRE_MED
  34. ORDER BY
  35.     pm.DT_PRE_MED ASC) presc
  36. ;
  37.  
  38. SELECT
  39.     *
  40. FROM
  41.     PRE_MED pm
  42. ;
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