1、day函数 定义:

DAY函数返回指定日期的日的部分

语法:

DAY(date)

参数:

①date参数是合法的日期表达式。

返回值:

int型数据 2、substr函数格式 (俗称:字符截取函数)   格式1: substr(string string, int a, int b);

  格式2:substr(string string, int a) ;

解析:

格式1:
    1、string 需要截取的字符串
    2、a 截取字符串的开始位置(注:当a等于0或1时,都是从第一位开始截取)
    3、b 要截取的字符串的长度

格式2:
    1、string 需要截取的字符串
    2、a 可以理解为从第a个字符开始截取后面所有的字符串。
SELECT DAY(date) as day,
COUNT(question_id) AS question_cnt
FROM question_practice_detail
WHERE SUBSTR(date,1,7)='2021-08'
group by day