You are on page 1of 18

Buatlah dua tabel seperti gambar pada contoh dan memberi relasi yang sesuai (sudah)

1. Langkah pertama membuat database pada sqlyog.


Pilih daabase create database atau Ctrl+D

2. Berinama database
3. Membuat Table
Klik kanan Create Table

Tabel Player

Tabel Team
4. Menginputkan data pada tabel player

5. Menginputkan data team


Menghitung total salary yang dimiliki oleh tiap-tiap team

SELECT * FROM player WHERE team = 'Indiana Pacers';

SELECT SUM(salary) AS total_team_Indiana_Pacers FROM player WHERE team = '


Indiana Pacers'

SELECT * FROM player WHERE team = 'New Jersey Nets';

SELECT SUM(salary) AS total_team_New_Jersey_Nets FROM player WHERE team = '


New Jersey Nets''
SELECT * FROM player WHERE team = 'New Orleans Hornets';

SELECT SUM(salary) AS total_team_New_Orleans_Hornets FROM player WHERE


team = 'New Orleans Hornets'
SELECT * FROM player WHERE team = 'Oklahoma City Thunder';

SELECT SUM(salary) AS total_team_Oklahoma_City_Thunder FROM player


WHERE team = 'Oklahoma City Thunder'

SELECT * FROM player WHERE team = 'Orlando Magic';

SELECT SUM(salary) AS total_team_Orlando_Magic FROM player WHERE team


= 'Orlando Magic'
Tampilkan total rata-rata penonton team Indiana Pacers dan Oklahoma City Thunder

SELECT SUM(Average_Attedence_2007_2008 + Average_Attedence_2008_2009 +


Average_Attedence_2009_2010)

AS total_rata2_penonton_Oklahoma_City_Thunde FROM team WHERE name_team =


'Oklahoma City Thunde';
SELECT SUM(Average_Attedence_2007_2008 + Average_Attedence_2008_2009 +
Average_Attedence_2009_2010)

AS total_rata2_penonton_Indiana_Pacers FROM team WHERE name_team = 'Indiana


Pacers';
SELECT DISTINCT name_team, Home_Ground, Average_Attedence_2007_2008 FROM team WHERE
Average_Attedence_2007_2008 <16000

SELECT DISTINCT name_team, Home_Ground, Average_Attedence_2007_2008 FROM team WHERE


Average_Attedence_2007_2008 >18000
SELECT DISTINCT name_team, Home_Ground, Average_Attedence_2007_2008 FROM team WHERE
Average_Attedence_2007_2008 >16000

OR average_attedence_2007_2008 >18000

INSERT INTO player (player_code, name_player, age, team, position_player, jersey_number, salary)

VALUE ('PTB_5','Rudy Fernandez','25','Portland Trail Blazers','Guard','5','1246680');


INSERT INTO player (player_code, name_player, age, team, position_player, jersey_number, salary)

VALUE ('LAL_16','Pau Gasol','30','LA Lakers','Forward','16','17822187');

INSERT INTO player (player_code, name_player, age, team, position_player, jersey_number, salary)

VALUE (' ','Steve Nash','36',' ','Guard',' ',' ');


6. UPDATE player SET player_code='IP_13',age='36',team='Indiana
Pacers',position_player='Guard',jersey_number='13',salary ='10310938' WHERE
name_player='Pau Gasol';

UPDATE player SET player_code='AH_07',age='26',team='Atlanta


Hawks',position_player='Guard',jersey_number='7',salary ='9800000' WHERE
name_player='J.J Redick';
7. Drop table players dan