Anonymous user
Run-length encoding: Difference between revisions
code sample changed to PL/pgSQL
(sql language example added) |
(code sample changed to PL/pgSQL) |
||
Line 2,889:
=={{header|SQL}}==
{{works with|
* RLE encoding
<lang
-- variable table
drop table if exists var;
set @string = 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW'▼
create temp table var ( value varchar(1000) );
▲
-- select
with recursive
ints(num) as
(
Line 2,902 ⟶ 2,905:
select num+1
from ints
where num+1 <=
)
,
Line 2,910 ⟶ 2,913:
from (
select num,
substring(
(select substring(
from ints
) tmp
)
select
select string_agg(concat(cast(maxNoWithinGroup as varchar(10))
from (
select *, max(noWithinGroup) over (partition by chr, groupNo) maxNoWithinGroup
Line 2,935 ⟶ 2,938:
) final
where noWithinGroup = 1
) Rle_Compressed
</lang>
|