Mysql 当分组记录为空时设置列值

Mysql 当分组记录为空时设置列值,mysql,Mysql,我有下面的查询,它返回分组的行。 对于返回空值的列mc_name,是否有任何方法可以在不更改记录数据的情况下设置值 以下是查询: select megaagents.megaagent_name AS 'mc_name', SUM(IF(MONTH(properties.created_at) = 1, 1, 0)) as ENE, SUM(IF(month(properties.created_at) = 2, 1, 0)) AS FEB, SUM(IF(mo

我有下面的查询,它返回分组的行。 对于返回空值的列mc_name,是否有任何方法可以在不更改记录数据的情况下设置值

以下是查询:

select
    megaagents.megaagent_name AS 'mc_name',
    SUM(IF(MONTH(properties.created_at) = 1, 1, 0)) as ENE,
    SUM(IF(month(properties.created_at) = 2, 1, 0)) AS FEB,
    SUM(IF(month(properties.created_at) = 3, 1, 0)) as MAR,
    SUM(IF(month(properties.created_at) = 4, 1, 0)) AS ABR,
    SUM(IF(month(properties.created_at) = 5, 1, 0)) AS MAY,
    SUM(IF(month(properties.created_at) = 6, 1, 0)) as JUN,
    SUM(IF(month(properties.created_at) = 7, 1, 0)) as JUL,
    SUM(IF(month(properties.created_at) = 8, 1, 0)) AS AGO,
    SUM(IF(month(properties.created_at) = 9, 1, 0)) as SEP,
    SUM(IF(month(properties.created_at) = 10, 1, 0)) as OCT,
    SUM(IF(month(properties.created_at) = 11, 1, 0)) as NOV,
    SUM(IF(month(properties.created_at) = 12, 1, 0)) as DIC,
    COUNT(PROPERTIES.PROP_EXCLUSIVE) AS TOTAL
from
  `properties`
  left join `megaagents` on `properties`.`megaagent_id` = `megaagents`.`id`
where
  `properties`.`marketcenter_id` = 11
  and `properties`.`prop_exclusive` in ('No Exclusiva', 'Exclusiva')
  and `properties`.`prop_transaction` in ('Alquiler Temporal', 'Alquiler', 'Venta')
group by
  `megaagents`.`megaagent_name`
order by
  `megaagents`.`megaagent_name` asc
问候

使用:

使用:


尝试:
选择IFNULL(megagents.megagent\u name,'MyValue')作为“mc\u name”…
。谢谢@wchiquito,这是另一种解决方法!!也行!尝试:
选择IFNULL(megagents.megagent\u name,'MyValue')作为“mc\u name”…
。谢谢@wchiquito,这是另一种解决方法!!也行!
select
    coalesce(megaagents.megaagent_name, 'custom value') AS mc_name,
....................................................................