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 prices (
id INT,
price DECIMAL(18,2),
type VARCHAR(5)
);
INSERT INTO prices VALUES
(1, 19.99, 'PERM'),
(1, 30.13, 'TEMP'),
(2, 14.44, 'SOME');
select id,max(price) as price from prices
where type='temp'
group by id
union
select id,max(price) from prices t1
where not exists( select 1 from prices t2 where t1.id=t2.id
and type='temp')
group by id
id price
1 30.13
2 14.44