Creo que está intentando acceder a validFrom
y validTo
de la consulta case en la condición where. Si ese es el caso, debe volver a formatear su consulta.
SELECT t1.* FROM ( SELECT mPrice, aPrice,
CASE
WHEN validFrom < '2013-11-01'
THEN '2013-11-01'
ELSE validFrom END AS validFrom,
CASE
WHEN validTo > '2013-11-30'
THEN '2013-11-30'
ELSE validTo END AS validTo
FROM commission) t1
WHERE ((t1.validfrom BETWEEN '2013-11-01' AND '2013-11-30') OR (t1.validto BETWEEN '2013-11-01' AND '2013-11-30')) ORDER BY t1.validFrom
Pero esto devolverá 3 resultados. Si necesita obtener el resultado esperado, debe usar AND
condición en lugar de OR
.
Entonces su consulta será
SELECT t1.* FROM ( SELECT mPrice, aPrice,
CASE
WHEN validFrom < '2013-11-01'
THEN '2013-11-01'
ELSE validFrom END AS validFrom,
CASE
WHEN validTo > '2013-11-30'
THEN '2013-11-30'
ELSE validTo END AS validTo
FROM commission) t1
WHERE ((t1.validfrom BETWEEN '2013-11-01' AND '2013-11-30') AND (t1.validto BETWEEN '2013-11-01' AND '2013-11-30')) ORDER BY t1.validFrom