create table brands 
(
category varchar(20),
brand_name varchar(20)
);
insert into brands values
('chocolates','5-star')
,(null,'dairy milk')
,(null,'perk')
,(null,'eclair')
,('Biscuits','britannia')
,(null,'good day')
,(null,'boost');

-- with cte as
--     (
-- select *, row_number() over()as rn 
--     from brands
-- )
-- ,cte2 as
--     (select *,count(category) over(order by rn) as rn2 from cte
-- )
--     select b.category,a.brand_name from cte2 a
--     left join(
-- select category,rn2
--     from cte2 a
--     where category is not null) b on a.rn2=b.rn2
with ct as (
    select *,row_number() over() as rn
    from brands
)
    ,ct2 as (
select category,brand_name, sum(case when category is null then 0 else 1 end) over(order by rn) as rnk
from ct
    )
select max(category) over(partition by rnk) as category,brand_name
from ct2

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: