motor-admin / motor-admin-rails

Low-code Admin panel and Business intelligence Rails engine. No DSL - configurable from the UI. Rails Admin, Active Admin, Blazer modern alternative.
https://app.getmotoradmin.com/demo/
MIT License
767 stars 77 forks source link

MySQL blank screen - Pie Chart - percent format #133

Open estebanutz opened 1 year ago

estebanutz commented 1 year ago

I'm experiencing something similar with this MySQL query. I get a blank screen using the "Percent" format on a pie chart. Running it on my MySQL client, I get a count result for both statuses but a blank screen in the admin area. With my data, I'm getting 75 verified and 25 pending. When I select "Table" to "Display as" it shows the table with the correct data.

Is there something I'm doing wrong? Thanks for the help! Here's the query below:

SELECT status_description,
    FORMAT(COUNT(1) / total_count * 100, 0) AS count
FROM (
    SELECT
        c.status,
        CASE
            WHEN status = 0 THEN 'Pending'
            WHEN status = 1 THEN 'Verified'
            ELSE 'Unknown'
        END AS status_description
    FROM customers as c
) AS subquery
CROSS JOIN (
    SELECT COUNT(1) AS total_count
    FROM customers
) AS total_counts
GROUP BY status_description, total_count;