I have a table where i store all product orders.
I need to count the number of closed and failed orders grouped by dealer and months and the percentage of failed orders and the number requests of extra info .
Table looks like this:
order id | status | dealer_id | month | area | requests
1 Closed 1 4 N "extra info"
2 failed 2 4 S "extra info"
3 failed 2 4 S 0
The sample result set would be:
dealer | month | Total | % Failed | Requested info
1 4 1 0 0
2 4 2 100 % 1
This query seems to work, using SQLite on Linux:
Please check if that works for your requirements and give feedback!