1
I would like help on a subject.
I have a query that lists requests(orders), and each request has its status, for example: 'confirmed', 'refused' and 'unmarked', I would like to create a Select that unites these status, for example, 'confirmed' is a status, 'refused' and 'unmarked' as being a single status, that is, a way of grouping two different values into one
Query:
SELECT monthname(o.processed_timestamp) AS Mês,
o.status,
count(1)
FROM orders_received.partner_commerce_item o
WHERE o.status IN ('confirmado',
'recusado',
'naoconfirmado')
GROUP BY month(o.processed_timestamp),
o.status;
The way this will be listed the orders in three different status, wanted to create something like:
SELECT monthname(o.processed_timestamp) AS Mês,
o.status,
count(1)
FROM orders_received.partner_commerce_item o
WHERE o.status = 'confirmado'
OR o.status in ('recusado','naoconfirmado') as recusados
GROUP BY month(o.processed_timestamp),
o.status;
But this way presents syntax error
I’ve tested it in various ways and I haven’t found one that works, so if you have any idea how to do that, it would be helpful.
Thanks for the tip @Bacco
– Willson Ferreira
Thanks!! It worked great using IF.
– Danilo Gimenes