当前位置:网站首页>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
边栏推荐
- leetcode621. 任务调度器
- ADB basic commands
- Redis database persistence
- Jerry's watch time synchronization [chapter]
- Embedded software development
- 【笔耕不辍勋章活动】生命不止,写作不息
- Essential for operation and maintenance - Elk log analysis system
- Unity SKFramework框架(十七)、FreeCameraController 上帝视角/自由视角相机控制脚本
- nohup命令
- Professor of Shanghai Jiaotong University: he Yuanjun - bounding box (containment / bounding box)
猜你喜欢
Why is the default of switch followed by break?
MAC (MacOS Monterey 12.2 M1) personal use PHP development
How to modify the error of easydss on demand service sharing time?
基于ssm+jsp框架实现的学生选课信息管理系统【源码+数据库】
Answer: can the audio be set to on by default during easydss video on demand?
Unity SKFramework框架(十七)、FreeCameraController 上帝视角/自由视角相机控制脚本
(6) Web security | penetration test | network security encryption and decryption ciphertext related features, with super encryption and decryption software
SAP MM 因物料有负库存导致MMPV开账期失败问题之对策
Unity SKFramework框架(十四)、Extension 扩展函数
Redis数据库持久化
随机推荐
无向图的桥
日本赌国运:Web3.0 ,反正也不是第一次失败了!
互联网常见34个术语解释
Error function ERF
De4000h storage installation configuration
SSL证书的分类有哪些?如何选择合适的SSL证书?
Fully autonomous and controllable 3D cloud CAD: crowncad's convenient command search can quickly locate the specific location of the required command.
OpenApi-Generator:简化RESTful API开发流程
2、 Frame mode MPLS operation
[indomitable medal activity] life goes on and writing goes on
免费SSL证书知多少?免费SSL证书和收费SSL证书的区别
Solve "sub number integer", "jump happily", "turn on the light"
JS逆向之行行查data解密
Performance optimization of memory function
Word efficiency guide - word's own template
[技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术
Unity SKFramework框架(十九)、POI 兴趣点/信息点
Fundamentals of machine learning (II) -- division of training set and test set
Unity skframework framework (XX), VFX lab special effects library
We sincerely invite young creators to share with investors and entrepreneurs how to make choices in life in the metauniverse