当前位置:网站首页>SQL statement writing
SQL statement writing
2022-06-10 01:30:00 【Come on, Haohao】
1、 Conditions of the query
<select id="queryPageList" resultType="com.netintech.api.kuap.uap.domain.ext.UapApplicationAuditList">
SELECT ad.*,
app.app_name AS appName,
p.apply_dept AS applyDept,
app.app_type AS appType
FROM uap_application_audit ad,
uap_app_release r,
uap_project_application app,
uap_project p
WHERE
ad.app_release_id = r.id
AND r.app_pk = app.id
AND app.project_id = p.id
<if test="auditResult != null">
AND ad.audit_result = #{auditResult}
</if>
AND app.app_name LIKE concat('%', #{appName}, '%')
AND p.apply_dept LIKE concat('%', #{applyDept}, '%')
</select>
2、 Multi table sort
<select id="deptApplicationRanking" resultType="com.netintech.vo.RankVo">
SELECT d.total AS count,
d.dept_id AS deptId,
d.dept_name AS deptName
FROM (
SELECT SUM(c.total) AS total,
c.dept_id,
c.dept_name
FROM (
SELECT COUNT(1) AS total,
u.app_department AS dept_id,
u.app_department_name AS dept_name
FROM uap_market_app u
GROUP BY u.app_department,
u.app_department_name
UNION ALL
SELECT COUNT(1) AS total,
p.dept_id AS dept_id,
p.dept_name AS dept_name
FROM uap_project_application p
GROUP BY p.dept_id,
p.dept_name
) c
GROUP BY c.dept_id,
c.dept_name
) d
ORDER BY d.total DESC
LIMIT 10;
</select>
3、 Add and sort the fields in the table
<select id="starAppListByShareApplication" resultType="com.netintech.vo.RankVo">
SELECT r.appname AS deptName, r.appid AS deptId, m.`download` + m.`collection` + m.`to_view` AS COUNT
FROM uap_supermarket_app m,
(SELECT u.`id` AS appid, u.`app_name` AS appname
FROM uap_shared_application u) r
WHERE m.`app_id` = r.appid
ORDER BY COUNT DESC
limit 3
</select>
边栏推荐
- 1265_FreeRTOS中向任务就绪链表增加任务的实现分析
- 腾讯Libco协程开源库 源码分析(一)---- 下载Libco 编译安装 尝试运行示例代码
- 牛客网——华为题库(1~10)
- Web3 is crucial to the data sovereignty of the meta universe
- Mongodb open source "queryable encryption" system
- Think of GPL as a "virus"? Please stop defaming GPL
- Regular expression does not contain a string
- From these papers in 2022, we can see the trend of recommended system sequence modeling
- 【Proteus仿真】51单片机+LCD1602+外置存储器计算器
- 亚洲首屈一指的Web3盛事“TOKEN2049新加坡”公布冠名赞助商
猜你喜欢

My eclipse connection database

星环科技科创板IPO过会:毛利率维持较高水平,腾讯等为主要股东

电脑系统怎么修改图片格式

图片批量下载 +图片马赛克:多张图片组成端午安康

国内现货白银有哪些好技术:常见指标的简单用法

【无标题】416. 分割等和子集

Domain Adaptation and Graph Neural Networks

有机金属多孔材料MOF(Fe)包载喜树碱,藤黄酸、吲哚菁绿|RMOF-3包载紫杉醇定制

CocosCreator旧活新整-合成大粽子

How to implement complex SQL such as distributed database sub query and join?
随机推荐
Picture batch download + picture mosaic: multiple pictures constitute the Dragon Boat Festival Ankang!
What if win11 returns win10 without a return option?
【LeetCode】105. 从前序与中序遍历序列构造二叉树
【ICLR 2022】Towards Continual Knowledge Learning of Language Models
Force deduction solution summary 497 random points in non overlapping rectangles
短视频直播源码,自定义图片或视频的循环播放
[從零開始學習FPGA編程-16]:快速入門篇 - 操作步驟2-4- Verilog HDL語言描述語言基本語法(軟件程序員和硬件工程師都能看懂)
Regular expression does not contain a string
【图像分类案例】(10) Vision Transformer 动物图像三分类,附Pytorch完整代码
Practice of Flink CDC + Hudi massive data entering the lake in SF
How can I right-click win11 to open all options directly?
Web3对元宇宙的数据主权至关重要
Teaching Broad Reasoning Skills via Decomposition-Guided Contexts
Locust: a powerful tool for microservice performance testing
电脑系统怎么修改图片格式
视频汇聚平台EasyCVR级联EasyCVR出现通道频繁掉线是什么原因?
【程序人生】“阶段总结”-不知所措
【LeetCode】接雨水
shell xxx. sh: line 284: return: -1: invalid option
Thingsboard tutorial (18): overview of TB rule engine