add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table account_book_data (
Account int,
Type varchar(20),
Title varchar(20)
);
insert into account_book_data values
(123, 'Fantasy', 'Dune'),
(123, 'Sports', 'Jordan'),
(123, 'Biography', 'Dali'),
(456, 'Fantasy', 'Foundation'),
(456, 'Sports', 'Ali'),
(789, 'Biography', 'Nelson');
6 rows affected
select Account,max(case when Type = 'Fantasy' then Title end) as Fantasy,
max(case when Type = 'Sports' then Title end) as Sports,
max(case when Type = 'Biography' then Title end) as Biography
from account_book_data
group by Account
Account Fantasy Sports Biography
123 Dune Jordan Dali
456 Foundation Ali null
789 null null Nelson
Warning: Null value is eliminated by an aggregate or other SET operation.