当前位置:网站首页>【Mysql系列】工作常用sql集锦(持续更新)
【Mysql系列】工作常用sql集锦(持续更新)
2022-06-26 18:10:00 【JobsTribe】
汇总工作中常用到的sql。
获取毫秒级的当前时间
用到CURRENT_TIMESTAMP(3)。
select CURRENT_TIMESTAMP(3);
但是在指定字段时需要注意字段的类型也需要datatime(3)类型。
字段类型中,datetime(3) 是精确到毫秒级的,datetime默认是0,精确到秒级的。
如何统计某个接口调用的总次数?
用group by,如
SELECT
service,
app_key,
count(*)
FROM
trace_log t
WHERE
create_time BETWEEN '2020-04-01 00:00'
AND '2020-05-01 00:00'
GROUP BY
service,
app_key;
统计表中条数超过2条的数据
用聚合函数having
SELECT
service,
app_key
FROM
aa
GROUP BY
service
HAVING
count( * ) > 1;
查询第二名
用小于号,这样可以排除null
SELECT
max( VALUE )
FROM
customer
WHERE
VALUE
< ( SELECT max( VALUE ) FROM customer );
边栏推荐
- Leetcode interview question 29 clockwise print matrix
- Clion compiling catkin_ WS (short for ROS workspace package) loads cmakelists Txt problems
- Plt How to keep show() not closed
- Clion编译catkin_ws(ROS工作空间包的简称)加载CMakeLists.txt出现的问题
- A little experience of next (ITER (dataloader))
- ISO文件
- MySQL download and configuration MySQL remote control
- Eigen库计算两个向量夹角
- PC端录制扫515地机器人/scan数据
- 股票开账户如何优惠开户?现在在线开户安全么?
猜你喜欢

Image binarization

In and exceptions, count (*) query optimization

DoS及攻击方法详解

深度学习之Numpy篇

Solve the problem that each letter occupies a space in pycharm

Clion breakpoint single step debugging

JVM entry Door (1)

Padding percentage operation

vutils. make_ A little experience of grid () in relation to black and white images

Lm06 the mystery of constructing the bottom and top trading strategy only by trading volume
随机推荐
ISO documents
Data Encryption Standard DES security
Lm06 the mystery of constructing the bottom and top trading strategy only by trading volume
17.13 supplementary knowledge, thread pool discussion, quantity discussion and summary
图像二值化处理
Image binarization
Which securities company is better for a novice to open a stock trading account? How is it safer to speculate in stocks??
Runtimeerror: CUDA error: out of memory own solution (it is estimated that it is not applicable to most people in special circumstances)
利用递归实现求n位所有格雷码
MySQL的MVCC机制详解
Please advise tonghuashun which securities firm to choose for opening an account? Is it safe to open an account online now?
Plt How to keep show() not closed
JVM entry door (1)
JS cast
How to open a stock account? Is it safe to open an account online now?
数字签名论述及生成与优点分析
RSA encryption and decryption details
wechat_ Solve the problem of page Jump and parameter transfer by navigator in wechat applet
Leetcode interview question 29 clockwise print matrix
深层次安全定义剖析及加密技术