无法使用date函数获取结果

oknrviil  于 2021-06-19  发布在  Mysql
关注(0)|答案(1)|浏览(274)

我想用query检查条件

select min(date_format(date(time_stamp),'%Y-%m-%d'))as time_stamp,
       'FN' period,
       null count  ,
       null sheetno,
       if (count(min(date_format(date(time_stamp),'%Y-%m-%d')))=1 ,200,0) as amount  
from omr_verification

我想计算时间戳是否可用意味着金额=200,否则为0

dm7nw8vv

dm7nw8vv1#

您可以在select中使用if条件或case。

select min(date_format(date(time_stamp),'%Y-%m-%d'))as time_stamp,
   'FN' period,
   null count  ,
   null sheetno,
   if (time_stamp !='' ,200,0) as amount  from omr_verification

相关问题