当前位置:网站首页>MySQL circularly adds sequence numbers according to the values of a column
MySQL circularly adds sequence numbers according to the values of a column
2022-04-23 05:03:00 【Great Wall ol】
A table has a primary key id, One job number . Now the job number repeats , Find out all the duplicate data of the job number , And add... After the job number of these data 01,02,03
SELECT
rownu,
tb.jobid,
(rownum1 - d.minvalue)
FROM
(
SELECT
@rownum1 :=@rownum1 + 1 AS rownum1,
jobid
FROM
tablea,
(SELECT @rownum1 := 0) t
) tb
LEFT JOIN (
SELECT
min(rownum) minvalue,
jobid
FROM
(
SELECT
@rownum :=@rownum + 1 AS rownum,
jobid
FROM
tablea,
(SELECT @rownum := 0) t
) tc
GROUP BY
jobid
) d ON (tb.jobid = d.jobid);
The effect is as follows
版权声明
本文为[Great Wall ol]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220552270339.html
边栏推荐
- Innovation training (V) configuration information
- AQS source code reading
- Barcode generation and decoding, QR code generation and decoding
- 【数据库】MySQL基本操作(基操~)
- Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
- [2021] Spatio-Temporal Graph Contrastive Learning
- Uglifyjs compress JS
- Gets all dates between two times
- Analysis of POM files
- Use the built-in function of win to transfer files between two computers in the same LAN (the speed is the same as that between local disks)
猜你喜欢
【数据库】MySQL多表查询(一)
Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
跨境电商 | Facebook 和 Instagram:哪个社交媒体更适合你?
Thoughts on a small program
Sword finger offer: the median in the data stream (priority queue large top heap small top heap leetcode 295)
深度学习笔记 —— 数据增广
[2021] Spatio-Temporal Graph Contrastive Learning
View analysis of scenic spots in ArcGIS
Innovation training (VI) routing
Pixel 5 5g unlocking tutorial (including unlocking BL, installing edxposed and root)
随机推荐
Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
Deep learning notes - object detection and dataset + anchor box
redis和mysql区别
The applet calls the function of scanning QR code and jumps to the path specified by QR code
TypeError: ‘Collection‘ object is not callable. If you meant to call the ......
Acid of MySQL transaction
CLion+OpenCV identify ID number - detect ID number
[winui3] Écrivez une copie du gestionnaire de fichiers Explorer
Docker installation and mysql5 7 installation
Sword finger offer: push in and pop-up sequence of stack
The WebService interface writes and publishes calls to the WebService interface (I)
敏捷实践 | 提高小组可预测性的敏捷指标
JS determines whether the numeric string contains characters
2022/4/22
Informatics Olympiad 1955: [11noip popularization group] Swiss round | openjudge 4.1 4363: Swiss round | Luogu p1309 [noip2011 popularization group] Swiss round
Painless upgrade of pixel series
The difference between static pipeline and dynamic pipeline
Unity C e-learning (IV)
vscode ipynb文件没有代码高亮和代码补全解决方法
Com alibaba. Common methods of fastjson