How to format this kind of sql statement? Many of these sql statements look tired.

TO_CHAR(CAST(DECODE(COUNT(*),0,0,SUM(CASE WHEN pd.score >=(select qualiscore from tb_agent_crmscallappeal where appealid="1") THEN 1 ELSE 0 END)/COUNT(*)*100) AS NUMBER(10,2)),"990.00") || "%" AS qualifi,
Mar.15,2022

use tools, online or client, but your SQL is incomplete and may not be formatted correctly. I formatted it with navicat and it looks like the following

TO_CHAR (
    CAST(
        DECODE(
            COUNT(*),
            0,
            0,
            SUM(
                CASE
                WHEN pd.score >= (
                    SELECT
                        qualiscore
                    FROM
                        tb_agent_crmscallappeal
                    WHERE
                        appealid = '1'
                ) THEN
                    1
                ELSE
                    0
                END
            ) / COUNT(*) * 100
        ) AS NUMBER (10, 2)
    ),
    '990.00'
) || '%' AS qualifi,
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a62f-4124e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a62f-4124e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?