SQL - Nomor baris menjadi karakter alfabet
-- ROW NUMBER INTO ALPHABETICAL CHARACTER & CONCAT
WITH updateCode AS (
SELECT table2.id as typeId, table2.code as typeCode, table1.id as descId, Char(64 + row_number() over (partition by type_id order by table1.id)) as rowLetter
FROM table1
INNER JOIN table2 ON table1.type_id = table2.id
)
UPDATE table1
inner join updateCode on updateCode.descId = table1.id
set table1.code = CONCAT(typeCode, rowLetter)
where table1.type_id = typeId;
Avril Henry