dimanche 15 mars 2015

Select subquery inside then of case when statement, sqlite bug?

I'm finding that when I try to select a column in a SQL case statement, it doesn't work unless I wrap it in a numeric function. The max(price) seems to select the value in the column, while just price, or price always returns blank.


I think its a bug.


This doesn't work:



SELECT
auction,
CASE WHEN auction='1'
THEN (select max(bid.amount) from bid where bid.auction_id = auction.id)
ELSE price
END as price_string,
FROM product


This works:



SELECT
auction,
CASE WHEN auction='1'
THEN (select max(bid.amount) from bid where bid.auction_id = auction.id)
ELSE max(price)
END as price_string
FROM product

Aucun commentaire:

Enregistrer un commentaire