SHARE
TWEET

Untitled

a guest Nov 22nd, 2016 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT  (SELECT COUNT(*) AS 'Colaboradores'
  2.          FROM SRA010
  3.          WHERE RA_FILIAL = sd3.D3_FILIAL
  4.             AND (RA_SITFOLH NOT IN ('D', 'A') OR RA_DEMISSA  > CAST(YEAR(sd3.D3_EMISSAO) AS VARCHAR)+CAST(REPLICATE('0', 2 - LEN(MONTH(sd3.D3_EMISSAO))) + RTrim(MONTH(sd3.D3_EMISSAO)) AS VARCHAR)+'31')
  5.             AND RA_CC = foo.D3_CC) AS Pessoas
  6.  FROM SD3010 AS sd3
  7.  JOIN (SELECT sd3_cc.D3_CC
  8.        FROM SD3010 AS sd3_cc                                         
  9.        GROUP BY sd3_cc.D3_CC
  10.        ) AS foo ON (foo.D3_CC = sd3.D3_CC)
  11. WHERE sd3.D3_TM = '010'
  12.   AND sd3.D3_LOCAL IN ('01','02')
  13.   AND sd3.D3_FILIAL = '0301'
  14.  
  15.   AND sd3.D_E_L_E_T_ <> '*'
  16.  
  17.   AND sd3.D3_EMISSAO BETWEEN '20161001' AND '20161031'
  18.   AND sd3.D3_CC IN ('1350400', '1350403', '1350405', '1350408', '1350409', '1350410', '1350411', '1350412', '1350413', '1350414', '1350415', '1350416', '1350417', '1350418', '1350419', '1350420', '1350421', '1350422', '1350423', '1350424', '1350425', '1350426', '1350427', '1350428', '1350429', '1350430', '1350431', '1350432', '13604', '1360400', '1360401', '1360402', '1360499')
  19. GROUP BY sd3.D3_FILIAL, sd3.D3_EMISSAO, foo.D3_CC
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