Subject | Re: [firebird-support] Re: IF into SQL statement |
---|---|
Author | Radu Sky |
Post date | 2006-04-21T22:06:36Z |
majstoru wrote:
SpecPrice, Qty)
SELECT :ID, ArtId, ArtName, ArtBarcode, InPrice, OutPrice,
CASE
WHEN COALESCE(InPrice,0)=0 THEN <your alternate value here>
ELSE (OutPrice / InPrice) * 100
END,
Qty
FROM (SELECT ArtId, ArtName, ArtBarcode, (SELECT Price FROM QtyActual
WHERE Object = 1 AND ArtIdqty = ArtId) AS InPrice, (SELECT AVG(Price)
FROM QtyHistory WHERE Object = 1 AND ArtIdqty = ArtId) AS OutPrice,
Qty
FROM ArticleTable
WHERE ArticleTable.Id = :PARAM1)
HTH
Radu
> --- In firebird-support@yahoogroups.com, Radu Sky <skysword76@...>INSERT INTO RK (RKId, ArtId, ArtName, ArtBarcode, InPrice, OutPrice,
> wrote:
>> majstoru wrote:
>>> Is there any way to put IF condition or something like that to
> prevent
>>> NUll or 0 as result into InPrice?
>>
>> CASE statements wouldn't help?
>>
>> Radu
>>
>
> Hi Radu,
>
> Sounds great if it is possible, do you have a sample or a sintax of a
> CASE into SQL script!
>
> Thanks again!
>
SpecPrice, Qty)
SELECT :ID, ArtId, ArtName, ArtBarcode, InPrice, OutPrice,
CASE
WHEN COALESCE(InPrice,0)=0 THEN <your alternate value here>
ELSE (OutPrice / InPrice) * 100
END,
Qty
FROM (SELECT ArtId, ArtName, ArtBarcode, (SELECT Price FROM QtyActual
WHERE Object = 1 AND ArtIdqty = ArtId) AS InPrice, (SELECT AVG(Price)
FROM QtyHistory WHERE Object = 1 AND ArtIdqty = ArtId) AS OutPrice,
Qty
FROM ArticleTable
WHERE ArticleTable.Id = :PARAM1)
HTH
Radu