mysql按月份分组,按年份分组,以及date_format函数的英应用

SELECT
    YEAR (b.billStartDate) '年',
    MONTH (b.billStartDate) '月',
        b.billStartDate as createdDate,
        
     round(sum(b.realIncome),2) AS realIncome,
    date_format(b.billStartDate,'%Y-%m') as time
FROM
    hr_bills b
where b.merchantId=18
GROUP BY
    YEAR (b.billStartDate) ,MONTH (b.billStartDate)

 

获取年年月日

date_format(time,%Y-%m-%d')

你可能感兴趣的:(mysql按月份分组,按年份分组,以及date_format函数的英应用)