I have a problem with the following code:
select
sum(Subtotal) as faturamento,
cast(Created_At as date) as Dia
from Orders
where
(year(Created_At) = 2018 and month(Created_At) = 7)
or (Created_At between
‘2017-01-01’
and ‘2017-12-31’
)
or (Created_At between
dateadd(year, -1, '2017-01-01')
and dateadd(year, -1,'2017-12-31')
)
group by Dia
order by Dia
THE IDEA WAS TO MAKE A FILTER THAT RESPECTED THE FOLLOWING CONDITION:
dateadd(year, -1, ‘2017-01-01′)
and dateadd(year, -1,’2017-12-31’)
New contributor
Allyson Scharnowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.