题解 | #21年8月份练题总数#

21年8月份练题总数

https://www.nowcoder.com/practice/b8f30b239b454ed490367b53ea95607d

select 
count(distinct device_id) as did_cnt,
count(device_id) as question_cnt 
#或者count(question_id) as question_cnt  通过 
# count(distinct question_id) as question_cnt  G了
# 不可以用distinct 问的是题的总数,而不是有几类题。
from question_practice_detail
where month(date) = 8 and year(date) = 2021;

查找2021 8月份的方法

#date(最常用,其格式为:YYYY-MM-DD)
# month year函数
where month(date) = 8 and year(date) = 2021;
#date_format()
where date_format(date,'%Y%m') = '202108'; #Y
where date_format(date,'%y%m') = '2108' ;#y
#like 
where date like '2021-08%';
#substring():截取字符串中介于两个指定下标之间的字符。
where substring(date,1,7) = '2021-08'
#mid 有点像substring()
where mid(date,1,7) = '2021-08'
#substring_index(“待截取有用部分的字符串”,“截取数据依据的字符”,截取字符的位置N)
where substring_index(date,'-',2) = '2021-08'

全部评论

相关推荐

Lorn的意义:你这种岗位在中国现在要么牛马天天加班,要么关系户进去好吃好喝,8年时间,真的天翻地覆了,对于资本来说你就说一头体力更好的牛马,哎,退伍没有包分配你真的亏了。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务