我有sql查询
select
DISTINCT {fn MONTHNAME(entrydate)} AS monthname,
emirate_name,
location,
price,
bedroom
from itf_property
where
emirate_name='Dubai'
and location='JBR'
and bedroom='2'
group by monthname
order by id
我想从jan到dec选择null月,如果jan没有值则会显示0。
上述查询的输出是附加图像
答案 0 :(得分:0)
在mysql上使用if
select
DISTINCT {fn MONTHNAME(entrydate)} AS monthname,
emirate_name,
if(month is null, '0', month) as month,
location,
price,
bedroom
from itf_property
where
emirate_name='Dubai'
and location='JBR'
and bedroom='2'
group by monthname
order by id