Condicional en consulta

18/07/2004 - 23:05 por Juanqyf | Informe spam
como puedo hacer esto en una consulta de sql

select si((now()-FechaPedido)<,VentasTotales,0) As R1

No he podido utilizar un condicional en SQL, me dan la
mano porfa!!!

Atentamente
Juan Carlos DIaz Morillo
 

Leer las respuestas

#1 Gustavo Larriera [MVP SQL]
19/07/2004 - 00:47 | Informe spam
Debes usar la sentencia CASE, este es un ejemplo:

USE pubs
GO
SELECT 'Price Category' CASE
WHEN price IS NULL THEN 'Not yet priced'
WHEN price < 10 THEN 'Very Reasonable Title'
WHEN price >= 10 and price < 20 THEN 'Coffee Table Title'
ELSE 'Expensive book!'
END,
CAST(title AS varchar(20)) AS 'Shortened Title'
FROM titles
ORDER BY price
GO

Gustavo Larriera
Uruguay LatAm
http://sqljunkies.com/weblog/gux/
Este mensaje se proporciona "COMO ESTA" sin garantias y no otorga ningun
derecho / This posting is provided "AS IS" with no warranties, and confers
no rights.
"Juanqyf" wrote in message
news:2f20001c46d0a$fb4e4dd0$
como puedo hacer esto en una consulta de sql

select si((now()-FechaPedido)<,VentasTotales,0) As R1

No he podido utilizar un condicional en SQL, me dan la
mano porfa!!!

Atentamente
Juan Carlos DIaz Morillo

Preguntas similares