I have this table structure for table prices:
CREATE TABLE prices
(
id int,
priceFrom int,
priceUp int
);
INSERT INTO prices (id, priceFrom, priceUp)
VALUES (1, 23, 23), (2, 0, 0), (3, 12, 13),
(4, 40, 40), (5, 15, 15), (6, 0, 0);
This is the result:
I have this query:
select
pricefrom, priceup,
case
when pricefrom = 0 then null
when priceFrom <> priceUp then priceFrom + ' - ' + priceUp
when priceFrom = priceUp then priceFrom
end as FinalPrice
from
prices
what I need is to do a case when
- pricefrom = 0 then show null
- pricefrom = priceup then show the price
- At least if pricefrom != priceup I want to show for example this: 12(pricefrom) - 13(priceup)
but in my query in this line:
I try to do this with <> but in the result appears the sum for both numbers:
How can I fix this?
Aucun commentaire:
Enregistrer un commentaire