当前位置:网站首页>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
边栏推荐
- JS reverse row query data decryption
- Fully autonomous and controllable 3D cloud CAD: crowncad's convenient command search can quickly locate the specific location of the required command.
- Jerry's watch stops ringing [article]
- Ali on three sides, it's really difficult to successfully get the offer rated P7
- MAC (MacOS Monterey 12.2 M1) personal use PHP development
- Solve "sub number integer", "jump happily", "turn on the light"
- Error function ERF
- EasyDSS点播服务分享时间出错如何修改?
- 诚邀青年创作者,一起在元宇宙里与投资人、创业者交流人生如何做选择……...
- 题解《子数整数》、《欢乐地跳》、《开灯》
猜你喜欢
无向图的桥
Lucky numbers in the [leetcode daily question] matrix
Essential for operation and maintenance - Elk log analysis system
能自动更新的万能周报模板,有手就会用!
Error function ERF
De4000h storage installation configuration
OpenFOAM:lduMatrix&lduAddressing
Jerry's watch modifies the alarm clock [chapter]
三翼鸟两周年:羽翼渐丰,腾飞指日可待
操作教程:EasyDSS如何将MP4点播文件转化成RTSP视频流?
随机推荐
基于ssm+jsp框架实现的学生选课信息管理系统【源码+数据库】
2022零代码/低代码开发白皮书【伙伴云出品】附下载
Crowncad (crown CAD), the first fully independent 3D CAD platform based on Cloud Architecture in China
互联网常见34个术语解释
Countermeasures for the failure of MMPV billing period caused by negative inventory of materials in SAP mm
运维必备——ELK日志分析系统
JS reverse row query data decryption
Node.js通过ODBC访问PostgreSQL数据库
二、帧模式 MPLS 操作
Should I have a separate interface assembly- Should I have a separate assembly for interfaces?
Research shows that "congenial" is more likely to become friends
Jerry's weather code table [chapter]
Student course selection information management system based on ssm+jsp framework [source code + database]
Principle analysis of security rememberme
Unity SKFramework框架(十四)、Extension 扩展函数
OpenApi-Generator:简化RESTful API开发流程
Error function ERF
Unity SKFramework框架(十二)、Score 计分模块
挥发性有机物TVOC、VOC、VOCS气体检测+解决方案
linux下清理系统缓存并释放内存