Je pense que vous essayez d'accéder au validFrom
et validTo
à partir de la requête de cas dans la condition where. Si tel est le cas, vous devez reformater votre requête.
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
Mais cela renverra 3 résultats. Si vous devez obtenir le résultat attendu, vous devez utiliser un AND
condition au lieu de OR
.
Votre requête sera alors
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