Reputation: 5652
Is there an equivalent of the Oracle SQL DECODE
function in N1QL?
I.e. a function which allows you to choose to output one or other value, based on a conditional check:
select sum(decode(type = 'car', 1, 0)) carCount from mybucket
thanks
Upvotes: 1
Views: 187
Reputation: 7414
DECODE will be available in next release. In mean time you can use CASE expression
SELECT SUM(CASE WHEN type = 'car' THEN 1 ELSE 0 END) carCount
FROM mybucket;
Upvotes: 3