mysql中两列的总和

时间:2013-04-18 11:37:50

标签: asp.net mysql

我正在制作水晶报告,我正在制作基于效果的报告。这是我的查询

select mguser.userID, mguser.userName as Loger,date_format(trschedule.insDate,'%Y-%m-%d') as _Date,
count(distinct trschedule.scheduleID) as Schedule_Count, count(*) segment_count
FROM
mguser

我希望将这两列的总和--- count(distinct trschedule.scheduleID)作为Schedule_Count,count(*)segment_count

我怎样才能在mysql ???

中执行此操作

1 个答案:

答案 0 :(得分:2)

select Loger,_Date, (Schedule_Count + segment_count) sum from
(
  select mguser.userID, mguser.userName as Loger,
     date_format(trschedule.insDate,'%Y-%m-%d') as _Date,
     count(distinct trschedule.scheduleID) as Schedule_Count, 
      count(*) segment_count
  FROM
  mguser
)d