Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: SQL
Posted by: Hugo Felipe
Added: Mar 7, 2018 3:09 PM
Views: 8
Tags: no tags
  1. SELECT
  2.     CASE WHEN CHARINDEX('REFIN', nmProduto) > 0 THEN 'REFIN' ELSE 'NOVO' END AS produto,
  3.     nmBancoContaCredito,
  4.     SUM(COALESCE(vlLiberado, 0)) AS total_producao
  5. FROM DWA_ERP_PRODUCAO_BECT_HELP
  6. WHERE nrContrato IS NOT NULL
  7.       AND Backoffice = 2
  8.       AND cdLoja IN (33269, 40508, 40559, 49672, 50319, 50320, 36145, 50361, 50362, 50433, 50434, 50435, 50436, 50437, 39721, 36150, 50667, 8040, 8050, 50669, 8071, 8081, 50670, 50668, 8082, 9031, 49679, 6317, 40459, 50837, 50836, 50852, 50900, 50899, 50878, 50861, 33422, 41568, 50947, 41567, 50950, 34671, 50951, 40452, 50948, 50969)
  9.       AND CAST(dtContrato AS DATE) BETWEEN N'2018-03-06' AND N'2018-03-06'
  10. GROUP BY
  11.   (CASE WHEN CHARINDEX('REFIN', nmProduto) > 0 THEN 'REFIN' ELSE 'NOVO' END),
  12.   nmBancoContaCredito