此 soql 返回基于日期的结果计数;
SELECT day_only(createdDate) createdonDate,
count(createdDate) numCreated
FROM account
GROUP BY day_only(createdDate)
ORDER BY day_only(createdDate) desc
但我希望结果计数基于月份。
有没有办法在soql中实现这一点?
使用 CALENDAR_MONTH 函数:
select CALENDAR_MONTH (createdDate) createdonDate, count(ID) numCreated from account group by CALENDAR_MONTH (createdDate) order by CALENDAR_MONTH (createdDate) desc