SELECt
fname,
MonTH(eventDate),
SUM(IF(WEEKDAY(eventDate) < 5,1,0)) AS WeekdayCount,
SUM(IF(WEEKDAY(eventDate) >= 5,1,0)) AS WeekendCount
FROM eventcal AS e
LEFT JOIN users AS u ON e.primary = u.username
GROUP BY fname, MonTH(eventDate);
您要在SELECT中进行汇总(在这种情况下为SUM),然后按希望的方式按GROUP BY汇总(按fname,按MONTH)。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)