0

Hi all I use this query to get the sale of all the POS that I have on my DB, but now I want to know if there is a way to get the days where we dont get sales by ranges or get the specific dates where the sales were zero, I need is the dates and range of date where the sales is zero.

Usually I copy the result of the query to an Excel spreadsheet, create a pivot table and them manually check where I have empty cells and those are the days where I dont have sale for that POS.

Here the query

Select día,año,mes,

      c2.Super
        ,c3.Forma
        ,c1.pos
        ,c3.Desc_Pos
        ,c2.country
        ,sum([Ventas_valor_local]) as Ventas_Valor_Local
        ,(case when UPPER(c2.country) in( 'EL SALVADOR','PANAMÁ') then sum([Ventas_valor_local]) 
           else 
         sum([Ventas_valor_local] )/
            (select TasaDeCambio from DBP.[Prodution].[tbl_TasaDeCambio] 
            where mes = MONTH(getdate())-1 and Año=year(getdate()) and country =c2.country) end
          )as Ventas_Dollar
         ,SUM([Ventas_Unidades])as Ventas_Unidades
from Sales.[Prodution].[tbl_Raw_daily_Super] C1
left outer join dbP.[Prodution].[tbl_Cat_Super] C2 on c2.idCadena = c1.Cadena and c2.Holding = 'WM' and c1.country = c2.country
left outer join dbP.[Prodution].[tbl_Cat_Pos] c3 on c3.idCadena = c2.idCadena and c3.idPos = c1.Pos
where 
 Año=2016 
group by  día,año,mes,c2.Super,c1.pos,c3.Desc_Pos,c2.country,c3.Forma
order by día,año,mes,c2.Super,c1.pos,c3.Desc_Pos,c2.country,c3.Forma

I will appreaciat any advice

RARV
  • 31
  • 7
  • Thanks for the quick answer, but could you tell me how is this duplicated, because the structure of the query is what I want someone to help me with, because the query shows the sales and using the excel I will get the date that has empty values but I want to know if this query could be edited to get what I need now. – RARV Oct 24 '16 at 18:52
  • could you explain to me why you marked it like duplicated, I read several post of other questions that seems to be duplicated and even got a better answer than this. – RARV Oct 25 '16 at 16:46

0 Answers0