当前位置:网站首页>sql 使用过的查询语句
sql 使用过的查询语句
2022-04-23 06:56:00 【马虎的程序猿】
sql多表联查,进行每天数据统计
##复杂
SELECT
b.ds,
substring_index(
substring_index(a.key_words, '|', b.cotitle + 1),
'|',
-1
) course
FROM
search_task a
JOIN daily b on b.cotitle < (
length(a.key_words) - length(REPLACE(a.key_words, '|', '')) + 1
)
sql查询每日任务量(表中只有一条数据,进行多表联查,目标表的日期数据)
SELECT
b.ds,(
SELECT
COUNT(0)
FROM
tousu.heimao_search_task
) as count_i
FROM
mao_search a
JOIN video_daily b
GROUP by
ds
sql平均数
select ds,concat(
TRUNCATE(
(
(SELECT count(1) FROM wx_account_stat where company_id > 0)/
(SELECT count(1) FROM wx_account_stat where unit_nature='企业')
)
* 100,2),'%'
) as rate from wx_account_stat group by ds;
sql格式化日期
select DATE_FORMAT(update_time,'%Y-%m-%d') AS created from wx_accountc
sql字段添加
replace into video_collection_stat.video_daily (ds , cnt ,platform_name)
sql 计算每天增量(累计数据)
SELECT a.ds AS date_t,SUM(b.num) AS cum FROM
(SELECT sum(cnt) as num ,ds FROM video_daily GROUP BY ds) a
JOIN
(SELECT sum(cnt) as num ,ds FROM video_daily GROUP BY ds) b
ON a.ds >= b.ds GROUP BY a.ds
sql 去除空值进行计算
select cotitle, sum(cnt) as sum_int from video_daily
where cotitle!='' GROUP BY cotitle
sql 黑窗口时候使用(列显示)
查询:select * from t_copr_tort limit 1 \G;
sql (LEFT JOIN向上填充)
SELECT
a.ds,
COUNT(1)
FROM
(SELECT ds FROM yuqing_daily GROUP BY ds) a
LEFT JOIN
(SELECT DATE_FORMAT(beg_time, '%Y-%m-%d') AS ds FROM t_search_task) b
ON a.ds >= b.ds
GROUP BY a.ds
sql 前后相减(join)
SELECT a.day , a.account_number - b.account_number as ram_sum FROM
(SELECT DATE_FORMAT(DATE_SUB(day,INTERVAL 1 DAY),'%Y-%m-%d') as day,account_number from wx_public) AS a
JOIN
(SELECT day,account_number from wx_public) AS b
ON a.day = b.day
版权声明
本文为[马虎的程序猿]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45195493/article/details/124266855
边栏推荐
- Thinkphp6 + JWT realizes login verification
- Solidity IDE Remix中文版使用手册
- Positioning of high precision welding manipulator
- 【编程实践/嵌入式比赛】嵌入式比赛学习记录(二):基于TCP的图片流传输
- Ctf-misc summary
- Implementation of promise all
- Asynchronous learning
- DVWA靶场练习
- Planification du mouvement du manipulateur dans l'assemblage 3c
- Ctf-misc learning from start to give up
猜你喜欢
How to import Excel data in SQL server, 2019 Edition
Three minutes to teach you to use Houdini fluid > > to solve particle fluid droplets
Attack and defense world misc questions 1-50
LeetCode 1611. 使整数变为 0 的最少操作次数
SAP sto with billing process and configuration
MySQL--锁的奥秘--数据怎么锁
How does feign integrate hystrix
惨了,搞坏了领导的机密文件,吐血分享备份文件的代码技巧
高精度焊接机械臂定位
CTF attack and defense world brush questions 51-
随机推荐
Flutter之Provider共享数据的两种方式
Research on system and software security (2)
Go语学习笔记 - 数组 | 从零开始Go语言
Mobile web (Font Icon, plane conversion, color gradient)
Research on system and software security (I)
一篇文章看懂变量提升(hoisting)
Ubuntu安装Mysql并查询平均成绩
Implementation of promise all
数据库之MySQL——基本常用查询命令
How does feign integrate hystrix
Intranet penetration series: icmptunnel of Intranet tunnel (Master James Barlow's)
User manual of Chinese version of solidity ide Remix
Hump naming object
云计算技能大赛 -- openstack私有云环境 第二部分
Go语学习笔记 - 结构体 | 从零开始Go语言
利用sqlmap注入获取网址管理员账号密码
Asynchronous learning
Redis -- why is the string length of string emstr the upper limit of 44 bytes?
Solidity IDE Remix中文版使用手册
NLLLoss+log_SoftMax=CE_Loss