add
remove
language
chart
show hidden
hide
db<>fiddle
Db2
DocumentDB
DuckDB
Firebird
MariaDB
MySQL
Oracle
Postgres
SQL Server
SQLite
TimescaleDB
YugabyteDB
11.1
11.5
12.1
0.114 (MongoDB 7.0)
0.116 (MongoDB 7.0)
1.4 LTS
3.0
4.0
5.0
10.2
10.3
10.4
10.5
10.6
10.7
10.8
10.9
10.11
11.4
11.8
12.3
5.5
5.6
5.7
8.0
8.4
9.7
11g Release 2
18c
21c
23c
23ai
26ai
8.4
9.3
9.4
9.5
9.6
10
11
12
13
14
15
16
17
18
19 beta 4
2012
2014
2016
2017 (Linux)
2017
2019 (Linux)
2019
2022
2025
3.8
3.16
3.27
3.39
3.45
3.53
2.11
2.14
2.28
2.6
2.8
2.18
2024.2 LTS
2025.2 LTS
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
Sakila
no sample DB
Sakila
no sample DB
Sakila
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
HR
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
db<>fiddle Statistics
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
AdventureWorks
no sample DB
AdventureWorks
no sample DB
AdventureWorks
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
run
abort
markdown
clear
donate
feedback
about
By using db<>fiddle, you agree to license everything you submit by
Creative Commons CC0
.
CREATE TABLE Preferences ( `Student_ID` INTEGER, `Student_Name` VARCHAR(100), `Meat` INTEGER, `Vegetable` INTEGER, `Drink` INTEGER, `Dessert` INTEGER ); INSERT INTO Preferences (`Student_ID`, `Student_Name`, `Meat`, `Vegetable`, `Drink`, `Dessert`) VALUES ('1', 'Jeff', '3', '1', '4', '1'), ('2', 'Andrea', '1', '1', '3', '1'), ('3', 'Allison', '3', '2', '7', '1'), ('4', 'Randy', '1', '1', '4', '2'), ('5', 'Carl', '2', '5', '2', '2'), ('6', 'Bobby', '1', '6', '7', '2'), ('7', 'Julie', '3', '5', '2', '1'), ('8', 'Anna', '1', '6', '7', '2'), ('9', 'Carlos', '1', '6', '2', '2'), ('10', 'Roger', '2', '4', '2', '1'), ('11', 'Pierre', '1', '2', '1', '1'), ('12', 'Troy', '2', '3', '3', '1'), ('13', 'David', '3', '6', '6', '2'), ('14', 'Michaela', '1', '4', '5', '2'), ('15', 'Rose', '1', '4', '6', '1'), ('16', 'Anita', '3', '6', '6', '2'), ('17', 'Connor', '3', '3', '3', '1'), ('18', 'Eddie', '1', '2', '7', '1'), ('19', 'Karen', '3', '5', '5', '2'), ('20', 'Rachel', '3', '2', '2', '1');
CREATE TABLE `Key` ( `Item_Type` VARCHAR(9), `Item` VARCHAR(8), `Value` INTEGER ); INSERT INTO `Key` (`Item_Type`, `Item`, `Value`) VALUES ('Meat', 'Chicken', '1'), ('Meat', 'Beef', '2'), ('Meat', 'Fish', '3'), ('Vegetable', 'Carrots', '1'), ('Vegetable', 'Peas', '2'), ('Vegetable', 'Corn', '3'), ('Vegetable', 'Broccoli', '4'), ('Vegetable', 'Zucchini', '5'), ('Vegetable', 'Eggplant', '6'), ('Drink', 'Water', '1'), ('Drink', 'Milk', '2'), ('Drink', 'Juice', '3'), ('Drink', 'Cola', '4'), ('Drink', 'Lemonade', '5'), ('Drink', 'Tea', '6'), ('Drink', 'Punch', '7'), ('Dessert', 'Cake', '1'), ('Dessert', 'Pie', '2');
select Preferences.Student_ID ,Preferences.Student_Name ,max(case `Key`.Item_Type when 'Meat' then `Key`.item end) as Meat ,max(case `Key`.Item_Type when 'Vegetable' then `Key`.item end) as Vegetable ,max(case `Key`.Item_Type when 'Drink' then `Key`.item end) as Drink ,max(case `Key`.Item_Type when 'Dessert' then `Key`.item end) as Dessert from Preferences join `Key`on `Key`.Item_Type = 'Meat' and `Key`.value = Preferences.Meat or `Key`.Item_Type = 'Vegetable' and `Key`.value = Preferences.Vegetable or `Key`.Item_Type = 'Drink' and `Key`.value = Preferences.drink or `Key`.Item_Type = 'Dessert' and `Key`.value = Preferences.Dessert group by Preferences.Student_ID, Preferences.Student_Name order by Preferences.Student_ID
Student_ID
Student_Name
Meat
Vegetable
Drink
Dessert
1
Jeff
Fish
Carrots
Cola
Cake
2
Andrea
Chicken
Carrots
Juice
Cake
3
Allison
Fish
Peas
Punch
Cake
4
Randy
Chicken
Carrots
Cola
Pie
5
Carl
Beef
Zucchini
Milk
Pie
6
Bobby
Chicken
Eggplant
Punch
Pie
7
Julie
Fish
Zucchini
Milk
Cake
8
Anna
Chicken
Eggplant
Punch
Pie
9
Carlos
Chicken
Eggplant
Milk
Pie
10
Roger
Beef
Broccoli
Milk
Cake
11
Pierre
Chicken
Peas
Water
Cake
12
Troy
Beef
Corn
Juice
Cake
13
David
Fish
Eggplant
Tea
Pie
14
Michaela
Chicken
Broccoli
Lemonade
Pie
15
Rose
Chicken
Broccoli
Tea
Cake
16
Anita
Fish
Eggplant
Tea
Pie
17
Connor
Fish
Corn
Juice
Cake
18
Eddie
Chicken
Peas
Punch
Cake
19
Karen
Fish
Zucchini
Lemonade
Pie
20
Rachel
Fish
Peas
Milk
Cake