Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP ME PLEASE!!!

Status
Not open for further replies.

flac0

Programmer
Oct 31, 2001
22
UY
I NEED TO CONDITION THE FILTER OF MY QUERY WITH A WHEN CONDITION IN WHERE SECTION...IT DOESN'T WORK...HOW COULD I DO FOR...?

SELECT CM.IdCaja,CM.IdValor,CM.Fecha,CM.Hora,CM.NúmeroComprobante,CM.Monto,CM.Observaciones,Cajas.Nombre as CajNom,COM.Descripción as ComDesc
FROM CajasMovimientos CM
LEFT JOIN Cajas ON CM.IdCaja=Cajas.IdCaja
LEFT JOIN Comprobantes COM ON CM.IdComprobante=COM.IdComprobante
WHERE 1>0 AND CM.Monto>0 AND
CASE LEN(Cajas.IdValor)=0 THEN
CM.Monto<0
ELSE
CM.Total>=0
END
OREDER BY CM.Fecha
 
Try the following.

SELECT
CM.IdCaja,
CM.IdValor,
CM.Fecha,
CM.Hora,
CM.NúmeroComprobante,
CM.Monto,
CM.Observaciones,
Cajas.Nombre as CajNom,
COM.Descripción as ComDesc
FROM CajasMovimientos CM
LEFT JOIN Cajas
ON CM.IdCaja=Cajas.IdCaja
LEFT JOIN Comprobantes COM
ON CM.IdComprobante=COM.IdComprobante
WHERE 1>0
-- AND CM.Monto>0 -- How can this be > 0 and <0?
AND ((LEN(Cajas.IdValor)=0 AND CM.Monto<0)
OR (LEN(Cajas.IdValor)<>0 AND CM.Total>=0))

OREDER BY CM.Fecha Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top