Created
May 19, 2016 20:17
-
-
Save wviana/a2475ebc30d8bc5681ec8a977547df2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
LOC.NR_GEO_LCL as IdLocalidade, | |
cast(ROUND(IsNull(SUM(FAT.QT_DNC_VND), 0), 0) * -1 as decimal(15,6)) as Valor | |
FROM FATO_AGG_SEG FAT (nolock) | |
JOIN DIMENSAO_LOCALIDADE LOC (nolock) ON LOC.SK_DIM_LCL = FAT.SK_DIM_LCL | |
JOIN DIMENSAO_TEMPO TMP (nolock) ON TMP.SK_DIM_TMP = FAT.SK_DIM_TMP | |
AND TMP.NR_NVL_RSU = 2 | |
AND TMP.AN_MM between 201501 and 201512 | |
JOIN DIMENSAO_SEGMENTO SEG with(nolock) | |
ON SEG.SK_DIM_SGM = FAT.SK_DIM_SGM AND | |
SEG.NR_NVL_RSU = 2 AND SEG.NR_IDN_FNE_DAD = 3 | |
WHERE | |
LOC.NR_NVL_RSU = 9 AND LOC.NR_GEO_LCL IN (33004560501,33004560502,33004560503,33004560504,33004560505,33051090500,33051091000,33051091500,33055540500,33041440507,33041440506,33041440505,33041440504,33041440503,33041440502,33041440501,33039060500,33036090500,33035000521,33035000520,33035000519,33035000518,33035000517,33035000516,33035000512,33035000511,33035000510,33032031000,33032030500,33029081000,33029080700,33029080500,33028580500,33028090500,33025023000,33025022000,33025021500,33022700505,33022700504,33022700503,33022700502,33022700501,33020071500,33018011000,33018010500,33017022000,33017021500,33017021000,33017020500,33045570539,33045570538,33045570537,33045570536,33045570535,33045570534,33045570533,33045570532,33045570531,33045570530,33045570529,33045570528,33045570527,33045570526,33045570525,33045570524,33045570523,33045570522,33045570521,33045570520,33045570519,33045570517,33045570516,33045570515,33045570514,33045570513,33045570512,33045570511,33045570510,33045570509,33045570508,33045570507,33045570506) AND LOC.CD_NTZ_ARA_GGR = -1 | |
GROUP BY | |
LOC.NR_GEO_LCL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment