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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

BrianMH

Well-known Member
Joined
Mar 26, 2008
Messages
1,490
I doubt msquery can use the case function. You could try IIF instead.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,424
Messages
5,642,041
Members
417,251
Latest member
Dordrecht

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
Top