Forums Últimos mensajes - Powered by IBM
 

Porque no reconoce el campo en la Select?

23/02/2010 - 15:46 por Paul | Informe spam
Estoy con SQLSERVER 2008 y realizo la siguiente cnsulta:

SELECT t1.Id, t1.Descrip,
SUM(t2.Quants * (CASE t2.Inclos WHEN 0 THEN t2.PVC ELSE (t2.PVC/(1 +
(t1.Num/100.00))) END)) AS Suma
FROM Pare t1 INNER JOIN Fill t2
ON t1.id=t2.IdPare AND t1.Data BETWEEN '2010/01/01' AND '2010/02/28'
GROUP BY t1.Id, t1.Descrip
HAVING Suma>40

En el HAVING Suma, me dice que el campo no existe.
Comoùedo hacerlo?

Gracias
 

Leer las respuestas

#1 SayNoMore
23/02/2010 - 17:38 | Informe spam
On 23 feb, 11:46, Paul wrote:
Estoy con SQLSERVER 2008 y realizo la siguiente cnsulta:

SELECT t1.Id, t1.Descrip,
SUM(t2.Quants * (CASE t2.Inclos WHEN 0 THEN t2.PVC ELSE (t2.PVC/(1 +
(t1.Num/100.00))) END)) AS Suma
        FROM Pare t1 INNER JOIN Fill t2
        ON t1.id=t2.IdPare AND t1.Data BETWEEN '2010/01/01' AND '2010/02/28'
        GROUP BY t1.Id, t1.Descrip
        HAVING Suma>40

En el HAVING Suma, me dice que el campo no existe.
Comoùedo hacerlo?

Gracias



Es un campo calculado. En tal caso, pone la expresion completa en el
having y tiene que funcionar...seria algo asi

SELECT t1.Id, t1.Descrip,
SUM(t2.Quants * (CASE t2.Inclos WHEN 0 THEN t2.PVC ELSE (t2.PVC/(1 +
(t1.Num/100.00))) END)) AS Suma
FROM Pare t1 INNER JOIN Fill t2
ON t1.id=t2.IdPare AND t1.Data BETWEEN '2010/01/01' AND
'2010/02/28'
GROUP BY t1.Id, t1.Descrip
HAVING (SUM(t2.Quants * (CASE t2.Inclos WHEN 0 THEN t2.PVC ELSE
(t2.PVC/(1 +> (t1.Num/100.00))) END))) > 40

Preguntas similares