当前位置:网站首页>Add sequence number column to query results in MySQL
Add sequence number column to query results in MySQL
2022-07-02 13:32:00 【Mister procedural ape】
- The first one is , utilize SELECT A temporary table
SELECT
T2.num
FROM
(
SELECT
( @i := @i + 1 ) AS num,
T.groupName
FROM
( SELECT groupName, SUM( all_amt ) allAmt FROM app_agent WHERE `year_month` >= #{beginDateTime} AND `year_month` <= #{endDateTime} GROUP BY groupName ORDER BY allAmt DESC ) T,(
SELECT
@i := 0
) AS N
) T2
WHERE
T2.groupName = #{groupName}
- The second kind , Temporary variable
SET @i = 0;
SELECT
( @i := @i + 1 ) AS num,
T.*
FROM
( SELECT org_name, SUM( all_amt ) allAmt FROM app_agent WHERE `year_month` >= 202001 AND `year_month` <= 202012 GROUP BY org_name ORDER BY allAmt DESC ) T
边栏推荐
- 机器学习基础(二)——训练集和测试集的划分
- 为什么switch 的default后面要跟break?
- Three talking about exception -- error handling
- TVOC, VOC, VOCs gas detection + Solution
- Countermeasures for the failure of MMPV billing period caused by negative inventory of materials in SAP mm
- 2022 Heilongjiang provincial examination on the writing skills of Application Essays
- Explanation: here is your UFO, Goldbach conjecture
- Research shows that "congenial" is more likely to become friends
- Post order traversal sequence of 24 binary search tree of sword finger offer
- 二、帧模式 MPLS 操作
猜你喜欢

Fundamentals of face recognition (facenet)

Professor of Shanghai Jiaotong University: he Yuanjun - bounding box (containment / bounding box)

Unity SKFramework框架(十三)、Question 问题模块

Solution: Compression Technology (original version and sequel version)

Unity skframework framework (XIX), POI points of interest / information points

Unity skframework Framework (XVI), package manager Development Kit Manager

Can automatically update the universal weekly report template, you can use it with your hand!

Unity skframework framework (XV), singleton singleton

Unity SKFramework框架(十六)、Package Manager 開發工具包管理器

日本赌国运:Web3.0 ,反正也不是第一次失败了!
随机推荐
伙伴云表格强势升级!Pro版,更非凡!
验证失败,请检查您的回电网址。您可以按照指导进行操作
Solve "sub number integer", "jump happily", "turn on the light"
Unity SKFramework框架(十二)、Score 计分模块
Redis数据库持久化
能自动更新的万能周报模板,有手就会用!
诚邀青年创作者,一起在元宇宙里与投资人、创业者交流人生如何做选择……...
Unity SKFramework框架(十九)、POI 兴趣点/信息点
Error function ERF
What are eNB, EPC and PGW?
为什么switch 的default后面要跟break?
Unity skframework framework (XIV), extension extension function
Astro learning notes
numpy数组计算
记忆函数的性能优化
[error record] cannot open "XXX" because Apple cannot check whether it contains malware
How to modify the error of easydss on demand service sharing time?
Jerry's weather direction coding table [chapter]
JS逆向之行行查data解密
OpenFOAM:lduMatrix&lduAddressing