How to synthesize three pieces of data from the database into one piece of data

The table structure before

is like this

clipboard.png
2

clipboard.png
sql4alias_namealias_name2alias_name3

clipboard.png

Sep.26,2021

use the window function of oracle. The field of the screenshot cannot be seen clearly. Please indicate it in the way of col1,col2,col3

.
select *
from (
    select t.*, 
      row_number() over (partition by col1, col2, col3, col4 order by alias_id) as rank_id,
      lead(amount) over (partition by col1, col2, col3, col4 order by alias_id) as alias_name2,
      lead(amount, 2) over (partition by col1, col2, col3, col4 order by alias_id) as alias_name3
    from t
    order by col1, col2, col3, col4, alias_id
)
where rank_id = 1

according to the query results above, you can save to the temporary table first, and then reinsert the data from the temporary table after the source table is emptied.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea672e-1dd9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea672e-1dd9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?