stand
stand

Reputation: 139

Remove null value from result

I have this query which is below. How can I remove null-value from result of query? So that only one line is left

SELECT
    CASE
WHEN department = 'РФ' THEN
    avg_time
END AS `РФ`,
 CASE
WHEN department = 'ЕС' THEN
    avg_time
END AS `ЕС`,
 CASE
WHEN department = 'Аутсорс' THEN
    avg_time
END AS `Аутсорс`
FROM
    (
        SELECT
            department,
            (sum(apruv) / count(*) * 100) AS avg_time
        FROM
            report_designer
        WHERE TIMESTAMPDIFF(
            MINUTE,
            createdtime_spec,
            first_status_change
        ) <= 15
        GROUP BY
            department
    ) x

result of query is result

How can I remove null-value from result of query? So that only one line is left

Upvotes: 1

Views: 130

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 176324

One way is to use:

SELECT 
    (SELECT (sum(apruv) / count(*) * 100) AS avg_time
    FROM report_designer
    WHERE TIMESTAMPDIFF(MINUTE,createdtime_spec,first_status_change) <= 15
      AND department = 'РФ') AS `РФ`,
    (SELECT (sum(apruv) / count(*) * 100) AS avg_time
    FROM report_designer
    WHERE TIMESTAMPDIFF(MINUTE,createdtime_spec,first_status_change) <= 15
      AND department = 'EC') AS `EC`,
    (SELECT (sum(apruv) / count(*) * 100) AS avg_time
    FROM report_designer
    WHERE TIMESTAMPDIFF(MINUTE,createdtime_spec,first_status_change) <= 15
      AND department = 'Аутсорс') AS `Аутсорс`;

Upvotes: 1

Related Questions