HarryCallaghan
Board Regular
- Joined
- Jan 30, 2013
- Messages
- 50
Hello,
i have this query which I need to run in MSQUERY. It runs ok in SQL SERVER 2008 but when trying to run it in MSQUERY in order to get an automated report I get an error regarding the SUM(CASE) statement.
I would appreciate any help
i have this query which I need to run in MSQUERY. It runs ok in SQL SERVER 2008 but when trying to run it in MSQUERY in order to get an automated report I get an error regarding the SUM(CASE) statement.
Code:
select usuarios.nombre as Analista, sum(case when FP= 'f' then 1 else 0 end) as S, sum(case when fp <>'f' then 1 else 0 end) as M, count(*) as Total
from pedidos inner join pedidos_detalle on pedidos.codigo = pedidos_detalle.codigo and pedidos.serie = pedidos_detalle.serie left join clientes on clientes.codigo = pedidos.cliente_codigo and clientes.serie = pedidos.cliente_serie left join usuarios on usuarios.codigo = pedidos.usuario
where datediff(dd, pedidos.fecha, getdate()) < 30 and (clientes.nombre like '%c%' or clientes.nombre like '%f%')
group by usuarios.nombre
order by total desc
I would appreciate any help