>He realizado este SELECT en SQL-SERVER 2005 y me funciona perfecto, el problema está cuando quiero llevar dicho SELECT a un formulario de consultas en Visual Foxpro 9.0
>
>Ejemplo:
>select fecha_des,case when horario=1 THEN 'AM' ELSE 'PM' END AS HORARIO,
SUM(case when cod_lin='L01' THEN min_prod ELSE 0.00 END) AS MP1,
SUM(case when cod_lin='L01' THEN min_espe ELSE 0.00 END) AS ME1,
SUM(case when cod_lin='L01' THEN min_ocio ELSE 0.00 END) AS Mo1,
>SUM(case when cod_lin='L02' THEN min_prod ELSE 0.00 END) AS MP2,
SUM(case when cod_lin='L02' THEN min_espe ELSE 0.00 END) AS ME2,
SUM(case when cod_lin='L02' THEN min_ocio ELSE 0.00 END) AS Mo2,
>SUM(case when cod_lin='L03' THEN min_prod ELSE 0.00 END) AS MP3,
SUM(case when cod_lin='L03' THEN min_espe ELSE 0.00 END) AS ME3,
SUM(case when cod_lin='L03' THEN min_ocio ELSE 0.00 END) AS Mo3
from encnotdes GROUP BY fecha_des,horario ORDER BY fecha_des,horario
>
>
>¿Como Lo realizaria en Visual Foxpro 9.0?
>
>Muchas Gracias de Antemano.
Luis,
Try
select fecha_des,ICASE( horario=1, 'AM', 'PM') AS HORARIO,SUM(IIF(cod_lin='L01',min_prod, 0.00)) AS MP1,
SUM(IIF(cod_lin='L01',min_espe,0.00)) AS ME1,
etc. for other sums
from encnotdes GROUP BY fecha_des,horario ORDER BY fecha_des,2
CASE function in SQL Server translates into IIF or ICASE function in VFP.
If it's not broken, fix it until it is.
My Blog