当前位置:网站首页>[MySql]substr用法-查询表的某个字段的具体位数的值
[MySql]substr用法-查询表的某个字段的具体位数的值
2022-07-26 20:52:00 【洛央虲】
运用场景
需要查询表的某个字段的具体位数的值是多少时
用法:
substr(example,pos,length);
example:需要查询的字段名
pos:查询该字段具体的第XX位(注:这里的pos是从1开始,不是0)
length:查询从第XX位开始,长度为length的字符
示例
时间字段数据为:create_time=‘2021-02-05 10:30:00’
SELECT
'4.新增数数量_区间最大秒' AS 指标,
'20210101-202101231' AS 时间段,
times,
max(num) AS num
FROM
(
SELECT
SUBSTR(create_time, 1, 19) times,
count(DISTINCT id) AS num
FROM
db.t_user
WHERE
substr(create_time, 1, 10) BETWEEN '2021-01-01'
AND '2021-12-31'
AND sex= 'male'
AND is_flag = '1'
GROUP BY
SUBSTR(create_time, 1, 19)
) t
执行结果

边栏推荐
- JS click the picture to print the image
- [HCIA security] bidirectional nat
- 1-《PyTorch深度学习实践》-线性模型
- Arm Mali GPU的噩梦:三星、华为纷纷转向自研!
- 洛谷-线段覆盖-(区间排序问题总结)
- 制作一个可调整大小的元素
- Deepfake pinches his face. It's hard to tell whether it's true or false. Tom Cruise is more like himself than himself!
- A unified label space for entity relationship extraction
- FreeRTOS个人笔记-软件定时器
- :active vs :focus
猜你喜欢

2022年简历石沉大海,别投了,软件测试岗位饱和了....

5、 Applet error: message:error: system error, error code: 80058, desc of scope userLocation is empty

Industrial basic IFC - extract model structure tree

Alkbh1

TCP的粘包拆包问题解决方案

技术分享 | 服务端接口自动化测试, Requests 库的这些功能你了解吗?

留存收益率计算公式

Summary of common interview questions of operating system, including answers

补充—非线性规划

Solution to the problem of sticking and unpacking TCP
随机推荐
获取文本选择的方向
Number() VS parseInt()
滤波及失真
美国再次发难:禁止承包商采购这5家中国公司的设备与技术
Supplement - nonlinear programming
From manual test to automatic test, it only took me a few months to double my salary
Selenium自动化测试面试题全家桶
kalibr标定realsenseD435i --多相机标定
五、小程序报错:message:Error: 系统错误,错误码:80058,desc of scope.userLocation is empty
[question] browser get request with token
拖放表格行
日本批准向韩出口EUV光刻胶,三星、SK海力士危机或将缓解
Flextronics responded to the "seizure of Huawei materials" incident: deeply regretted, looking forward to continuing cooperation!
Tester: "I have five years of testing experience" HR: "no, you just used one year of work experience for five years."
织梦文档关键词维护不管用
Summary of common interview questions of operating system, including answers
一种用于实体关系抽取的统一标签空间
彻底搞通服务发现的原理和实现
Sort the table by clicking on the header
制作一个可调整大小的元素