SLQ sentence running in SQL SERVER 2008 doesn't WORK in MSQUERY EXCEL

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.

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
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,214,976
Messages
6,122,541
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top