1

我正在编写一份水晶报告,并且正在生成基于绩效的报告。这是我的查询

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) as Schedule_Count, count(*) segment_count

我怎么能在mysql中做到这一点???

4

1 回答 1

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
于 2013-04-18T11:44:35.530 回答