当前位置:网站首页>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
边栏推荐
- Smart business card applet business card details page function implementation key code
- 每周leetcode - 06 数组专题 7~739~50~offer 62~26~189~9
- 【Appium】测试时遇到手机内嵌H5页面的切换问题
- 编译原理题-带答案
- Thinkphp6 + JWT realizes login verification
- 巨头押注的全屋智能,正在驱动海信、华为、小米们「自我革命」
- 【问题解决】VS2019解决编译生成的exe文件打不开的情况
- Feign source code analysis
- [go] common concurrency model [generic version]
- Concours de compétences en informatique en nuage - - première partie de l'environnement cloud privé openstack
猜你喜欢

DVWA靶场练习

Ribbon start process

高精度焊接机械臂定位

雲計算技能大賽 -- openstack私有雲環境 第一部分

Draw a circle quickly in MATLAB (the one that can be drawn directly given the coordinates and radius of the center of the circle)

【Appium】测试时遇到手机内嵌H5页面的切换问题

Sto with billing cross company inventory dump return

利用sqlmap注入获取网址管理员账号密码

Positioning of high precision welding manipulator
![[untitled]](/img/bb/213d95b60651dfeadb239a70507506.png)
[untitled]
随机推荐
php高精度计算
【无标题】
Ignis公链的NFT生态发展:Unicorn.art的捐赠开发之路
[untitled]
[programming practice / embedded competition] learning record of embedded competition (II): picture streaming based on TCP
PHP generates short links: convert numbers to letters and letters to numbers
Go语学习笔记 - 异常处理 | 从零开始Go语言
数据安全问题已成隐患,看vivo如何让“用户数据”重新披甲
vivo,硬件安全的爱与雷霆
SAP self created table log function is enabled
浏览器中的 Kubernetes 和 IDE | 交互式学习平台Killercoda
干货!以点为形:可微分的泊松求解器
BUUCTF MISC刷題
渗透测试面试合集---HVV---
惨了,搞坏了领导的机密文件,吐血分享备份文件的代码技巧
Hump naming object
1216_ MISRA_ C standard learning notes_ Rule requirements for control flow
BUUCTF [极客大挑战 2019]EasySQL1
Positioning and decoration style
Quick rehearsal exercise