Mysql 根據時間統計總數


代碼寫法:

    SELECT
            date_format(examinee_pay_time, '%Y-%m-%d') as payDate,
            COUNT(examinee_id) As realityApplyCount, <!-- 日繳費次數 -->
            sum((CASE WHEN examinee_exam_score IS NULL THEN exam_fee ELSE 0 END )) as realityApplyFee, <!-- 日繳費金額 -->
            exam_id,
            exam_name,
            examinee_pay_status,
            examinee_exam_status
        FROM
            schoolexam
        INNER JOIN examinee e ON exam_id = exam_item_id    AND  exam_type = examinee_apply_type
                                    AND (examinee_exam_status != '4' OR ISNULL(examinee_exam_status))
                                    AND examinee_pay_status = "1"
        <where>  
            1 = 1           
        </where>
        GROUP BY 
            date_format(examinee_pay_time, '%Y-%m-%d')

結果如下:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM