SlideShare a Scribd company logo
1 of 116
S E L E C T
h t t p : / / s p a d a . t e k n o k r a t . a c . i d
SQL – OPERATOR ARITMATIKA
• Pada ekspresi SQL dengan tipe data Number dan Date dapat digunakan
operator aritmatika.
Operator Precedence Deskripsi
+ Tambah
- Kurang
* Kali
/ Bagi
SQL – OPERATOR ARITMATIKA
• Contoh: (jika memiliki kolom pada tabel employees) seperti di bawah ini
SQL – OPERATOR ARITMATIKA
• Contoh:
Jika menggunakan statement :
SELECT LAST_NAME, SALARY, SALARY+300
FROM EMPLOYEES;
SQL – OPERATOR ARITMATIKA
• Contoh: (Hasil)
SQL – OPERATOR ARITMATIKA
• Contoh: (Hasil)
SQL – OPERATOR ARITMATIKA
• Contoh 2 : (Jika menggunakan dua operator sekaligus)
SELECT LAST_NAME, SALARY, 12*SALARY+100
FROM EMPLOYEES;
SELECT LAST_NAME, SALARY, 12*(SALARY+100)
FROM EMPLOYEES;
SQL – OPERATOR ARITMATIKA
• Contoh 2 : Hasil Statement 1
SQL – OPERATOR ARITMATIKA
• Contoh 2 : Hasil Statement 2
SQL – OPERATOR ARITMATIKA
• Contoh 2 : Hasil Berbeda karena USING PARENTHESES
SQL ALIASES
SQL – ALIASES
• SQL aliases are used to temporarily rename a table or a
column heading.
• SQL aliases are used to give a database table, or a column in a
table, a temporary name.
• Basically aliases are created to make column names more
readable.
SQL – ALIASES
• SQL Alias Syntax for Columns
SELECT column_name AS alias_name
FROM table_name;
SQL – ALIASES
• Contoh: Kasus 1
• (Jika ingin membuat last_name menjadi name, dan
commission_pct menjadi comm)
SQL – ALIASES
• Contoh:
SELECT last_name AS name,
commission_pct AS comm FROM employees;
SQL – ALIASES
• Contoh: Hasil (Jika ingin membuat last_name menjadi name,
dan commission_pct menjadi comm)
SQL – ALIASES
• Contoh 2: Kasus 2
• (Jika ingin membuat last_name menjadi name, dan kolom
salary dikalikan 12 menjadi Annual Salary)
SQL – ALIASES
• Contoh 2: (Jika ingin membuat last_name menjadi name, dan
kolom salary dikalikan 12 menjadi Annual Salary)
SELECT last_name “Name”, salary*12 “Annual Salary”
FROM employees;
SQL – ALIASES
• Contoh 2: Hasil (Jika ingin membuat last_name menjadi
name, dan kolom salary dikalikan 12 menjadi Annual Salary)
SQL – ALIASES
• SQL Alias Syntax for Tables
SELECT column_name(s) FROM table_name AS
alias_name;
SQL – ALIASES
• Contoh for Table Columns:
• The following SQL Statement selects all the orders from the
Customer with CustomerID=4 (Around the Horn).
• We use the “Customers” and “Orders” tables, and give them
tables aliases of “c” and “o” respectively (Here we have used
aliases to make the SQL shorter).
SQL – ALIASES
• Tabel Customers
CustomerI
D
CustomerNam
e
ContactNam
e
Address City PostalCode Country
2 Ana Trujillo
Emparedados
y helados
Ana Trujillo Avda. de la
Constitución
2222
México
D.F.
05021 Mexico
3 Antonio
Moreno
Taquería
Antonio
Moreno
Mataderos
2312
México
D.F.
05023 Mexico
4 Around the
Horn
Thomas
Hardy
120 Hanover
Sq.
London WA1 1DP UK
SQL – ALIASES
• Tabel Orders
OrderID CustomerID EmployeeID OrderDate ShipperID
10354 58 8 1996-11-14 3
10355 4 6 1996-11-15 1
10356 86 6 1996-11-18 2
SQL – ALIASES
• Contoh Statement: (with aliases)
SELECT o.OrderID, o.OrderDate, c.CustomerName
FROM Customers AS c, Orders AS o
WHERE c.CustomerName="Around the Horn" AND
c.CustomerID=o.CustomerID;
SQL – ALIASES
• Contoh Statement: (without aliases)
SELECT Orders.OrderID, Orders.OrderDate,
Customers.CustomerName
FROM Customers, Orders
WHERE Customers.CustomerName="Around the Horn"
AND Customers.CustomerID=Orders.CustomerID;
SQL SELECT DISTINCT
SQL SELECT DISTINCT
• The SELECT DISTINCT statement is used to return only distinct
(diferent) values.
• In a table, a column may contain many duplicate values; and
sometimes you only want to list the different (distinct) values.
• The DISTINCT keyword can be used to return only distinct
(different) values.
SQL SELECT DISTINCT
• SQL SELECT DISTINCT Syntax
SELECT DISTINCT column_name,
column_name FROM table_name;
SQL SELECT DISTINCT
• Contoh : (Kasus 1)
SQL SELECT DISTINCT
• Contoh : (Kasus 2)
• The following SQL statement selects only the distinct values
from the "City" columns from the "Customers" table
SQL SELECT DISTINCT
• Contoh : (Kasus 2) Tabel Customer
CustomerID CustomerName ContactName Address City PostalCode Country
1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo
Emparedados y
helados
Ana Trujillo Avda. de la
Constitución 2222
México D.F. 05021 Mexico
3 Antonio Moreno
Taquería
Antonio
Moreno
Mataderos 2312 México D.F. 05023 Mexico
4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
SQL SELECT DISTINCT
• Contoh : (Kasus 2)
SELECT DISTINCT City FROM
Customers;
SQL – Operasi Pembanding
SQL – OPERATOR PEMBANDING
• Berikut ini Operator pembanding dalam SQL
Operator Meaning
= Equal to
> Greater than
>= Greater than or Equal to
< Less than
<= Less than or equal to
<> Not Equal to
SQL – OPERATOR PEMBANDING
• Contoh: (Jika ingin menampilkan salary kurang dari sama
dengan 3000
Last_name salary
Matos 2600
Vargas 2500
Jose 3100
Santos 3500
Marquez 3100
SQL – OPERATOR PEMBANDING
• Contoh: Statement
SELECT last_name, salary FROM
employees WHERE salary <= 3000;
SQL – OPERATOR PEMBANDING
• Contoh: Hasil
SQL – OPERATOR PEMBANDING
• Operator Pembanding Kondisi lainnya (Other Comparison
Conditions)
Operator Meaning
BETWEEN … AND …. Between two values
(inclusive)
IN (set) Match any of a list of values
LIKE Match a character pattern
IS NULL Is a null value
SQL BETWEEN
SQL – OPERATOR PEMBANDING
• The SQL BETWEEN Operator
• The BETWEEN operator selects values within a range.
• The values can be numbers, text, or dates.
SQL – OPERATOR PEMBANDING
• The SQL BETWEEN Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Below is a selection from the ‘Products’ table
ProductI
D
ProductName SupplierID CategoryI
D
Unit Price
1 Chais 1 1 10 boxes x 20BAGS 18
2 Chang 1 1 24 - 12 oz bottles 19
3 Aniseed Syrup 1 2 12 - 550 ml bottles 10
4 Chef Anton's Cajun Seasoning 1 2 48 - 6 oz jars 22
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Kasus :
• The following SQL statement selects all products with a price
BETWEEN 10 and 20
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Answer:
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Kasus :
• Bagaimana untuk menampilkan products diluar dari range 10
dan 20 ??
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Answer:
SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Kasus :
• The following SQL statement selects all products with a price
BETWEEN 10 and 20, but products with a CategoryID of 1,2, or
3 should not be displayed?
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Answer:
SELECT * FROM Products
WHERE (Price BETWEEN 10 AND 20)
AND NOT CategoryID IN (1,2,3);
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Kasus:
• The following SQL statement selects all products with a
ProductName beginning with any of the letter BETWEEN ‘C’
and ‘M’?
SQL – OPERATOR PEMBANDING
• Example of The SQL BETWEEN
• Answer:
SELECT * FROM Products
WHERE ProductName BETWEEN 'C' AND
'M';
SQL IN
SQL IN
• The IN operator allows you to specify multiple values in a
WHERE clause.
• SQL IN Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name IN
(value1,value2,...);
SQL IN
• Example : Below is a selection from the ‘Customers’ table
CustomerI
D
CustomerName ContactName Address City PostalCode Country
1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo
Emparedados y
helados
Ana Trujillo Avda. de la
Constitución 2222
México D.F. 05021 Mexico
3 Antonio Moreno
Taquería
Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
5 Berglunds snabbköp Christina Berguvsvägen 8 Luleå S-958 22 Sweden
SQL IN
• Case:
• The Following SQL Statement selects all customers with a
City of ‘London’ or ‘Berlin’?
SQL IN
• Answer:
SELECT * FROM Customers
WHERE City IN ('London‘, ‘Berlin’);
SQL LIKE Operator
SQL LIKE
• The LIKE operator is used in a WHERE clause to search for a
specified patern in a column.
• Gunakan kondisi LIKE untuk melakukan pencarian sebagian
nilai string.
• Kondisi pencarian dapat menggunakan symbol karakter
berikut:
• % : Menunjukkan nol/kosong atau sembarang beberapa
karakter.
• _ : menunjukkan sembarang 1 karakter
SQL LIKE
• The SQL LIKE Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;
SQL LIKE
• Example:
SQL LIKE
• Example:
• Kasus 1:
• Bagaimana menampilkan first_nama yang memiliki huruf
depan S?
SQL LIKE
• Example:
• Answer:
SQL LIKE
• Example:
• Kasus 2
• Bagaimana menampilkan nama terakhir yang huruf keduanya
mengandung huruf o?
SQL LIKE
• Example:
• Answer:
SQL LIKE
• Exercise:
CustomerID CustomerName ContactName Address City PostalCode Country
1 Alfreds
Futterkiste
Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo
Emparedados y
helados
Ana Trujillo Avda. de la
Constitución
2222
México D.F. 05021 Mexico
3 Antonio Moreno
Taquería
Antonio
Moreno
Mataderos 2312 México D.F. 05023 Mexico
4 Around the Horn Thomas Hardy 120 Hanover
Sq.
London WA1 1DP UK
5 Berglunds
snabbköp
Christina
Berglund
Berguvsvägen 8 Luleå S-958 22 Sweden
SQL LIKE
• Exercise:
1. How to selects all customers with a City starting with the letter
“s”?
2. How to selects all customers with a City ending with the letter
“s”?
3. How to selects all customers with a Country containing the
pattern “land”?
4. How to selects all customers with Country NOT containing the
SQL – USING THE NULL
CONDITIONS
• Example:
SQL Logical Conditions
LOGICAL CONDITIONS
• The AND, OR, & NOT operators are used to filter records
based on more than one condition.
Operator Arti
AND Returns TRUE, jika kedua kondisi adalah TRUE
OR Returns TRUE, jika salah satu kondisi adalah TRUE
NOT Returns TRUE, jika kondisi tersebut adalah False
LOGICAL CONDITIONS
• The SQL AND & OR Operators
• The AND operator display a record if both the first condition
AND the second condition are true.
• The OR operator displays a record if either the first condition
OR the second condition is true.
LOGICAL CONDITIONS
• Example : Below is a selection from the “Customers” table
Custo
merID
CustomerName ContactName Address City PostalCode Country
1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo Emparedados y
helados
Ana Trujillo Avda. de la
Constitución 2222
México D.F. 05021 Mexico
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden
LOGICAL CONDITIONS
• Example :
• Kasus 1
• How to Selects all customers from country “Germany”
AND the city “Berlin”, in the Customers table?
LOGICAL CONDITIONS
• Example :
• Answer 1
SELECT * FROM Customers
WHERE Country='Germany'
AND City='Berlin';
LOGICAL CONDITIONS
• Example :
• Kasus 2
• How to selects all customers from the city ‘Berlin” OR
“Munchen”, in the Customers table?
LOGICAL CONDITIONS
• Example :
• Answer 2
SELECT * FROM Customers
WHERE City='Berlin'
OR City='München';
LOGICAL CONDITIONS
• Example 3:
• Kasus 3
• How to selects all customers from the country “Germany”
AND the city must be equal to “Berlin” OR “Munchen”, in
the Customers table?
LOGICAL CONDITIONS
• Example 3:
• Answer 3
SELECT * FROM Customers
WHERE Country='Germany'
AND (City='Berlin' OR City='München');
LOGICAL CONDITIONS
• Using the NOT Operator
LOGICAL CONDITIONS
• Hasil:
SQL – OPERASI PEMBANDING
• Rules of Precedence
Order Evaluated Operators
1 Arithmetic Operators
2 Concatenation operator
3 Comparison conditions
4 IS [NOT] NULL, LIKE, [NOT] IN
5 [NOT] BETWEEN
6 NOT logical condition
7 AND logical condition
8 OR logical condition
SQL – OPERASI PEMBANDING
• Example of Rules of Precedence
SQL – OPERASI PEMBANDING
• Example of Rules of Precedence
FUNGSI AGREGAT
FUNGSI AGREGAT
• Fungsi Agregat dalam SQL adalah fungsi yang menerima
kumpulan atau koleksi dan mengembalikan nilai tunggal
sebagai hasilnya, seperti: Jumlah data, nilai minimum, nilai
maximum dan nilai rata-rata.
• Fungsi ini digunakan bersama dengan pernyataan SELECT.
JENIS FUNGSI AGREGAT
• Standar ISO mendefinisikan lima jenis fungsi agregat, yaitu:
Fungsi Penjelasan
SUM Digunakan untuk menghitung total nilai dari kolom
tertentu
COUNT Digunakan untuk menghitung jumlah record
AVG Digunakan untuk menampilkan nilai rata-rata dari suatu
kolom
MAX Digunakan untuk menampilkan nilai tertinggi dari suatu
kolom
MIN Digunakan untuk menampilkan nilai terendah dari suatu
JENIS FUNGSI AGREGAT
• Example :
• Berikut ini adalah latihan dalam menggunakan fungsi agregat.
• Buatlah tabel buku dengan struktur tabel sebagai berikut : ->
Next Slide
JENIS FUNGSI AGREGAT
• Example :
JENIS FUNGSI AGREGAT
• Example : Kita lihat deskripsi dari tabel buku.
JENIS FUNGSI AGREGAT
• Example : Masukkan data sebagai berikut
JENIS FUNGSI AGREGAT
• Example : Jika ditampilkan dari tabel buku
mysql> SELECT * FROM buku;
+-----------+------------------------+------------------+---------------+-------+-----------+------+----------------+
| kode_buku | judul_buku | pengarang | penerbit | tahun | kategori | harga| tgl_inventaris |
+-----------+------------------------+------------------+---------------+-------+-----------+------+----------------+
| B0001 | Harry Potter | JK Rowling | British Press | 2013 | Fiksi | 50000| 2015-03-01 |
| B0002 | Sistem Basis Data | Abdul Kadir | Andi Offset | 2013 | Buku Teks | 40000| 2015-03-01 |
| B0003 | Sistem Basis Data | Fathansyah | ITB Press | 2013 | Buku Teks | 30000| 2015-03-01 |
| B0004 | Prophet Muhammad | Amir Abdullah | Madina Press | 2014 | Biografi | 45000| 2015-03-01 |
| B0005 | Ketika Cinta Bertasbih | Habiburahaman ES | Madina Press | 2014 | Fiksi | 75000| 2015-02-01 |
| B0006 | Pemrograman Basis Data | Abdul Kadir | Andi Offset | 2015 | Buku Teks | 67000| 2015-02-01 |
+-----------+------------------------+------------------+---------------+-------+-----------+------+----------------+
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
1. Fungsi COUNT
Digunakan untuk menghitung jumlah record.
Example: Bagaimana menghitung jumlah jenis buku di dalam
tabel buku?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
1. Fungsi COUNT
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
1. Fungsi COUNT
Bagaimana cara menghitung jumlah record tabel buku dengan
nama kolom jum_rec?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
1. Fungsi COUNT
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
1. Fungsi COUNT
Bagaimana menghitung jumlah record untuh tahun 2013 yang
diberi nama jum_rec?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
1. Fungsi COUNT
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
2. Fungsi Agregat SUM
Fungsi SUM digunakan untuk menghitung total nilai dari kolom
tertentu.
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
2. Fungsi Agregat SUM
Bagaiamana untuk menghitung total harga dari kolom harga
dengan nama kolom menjadi total_harga?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
2. Fungsi Agregat SUM
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
2. Fungsi Agregat SUM
Bagaimana untuk menghitung total harga untuk tahun 2013
dari kolom kolom harga dengan nama kolom menjadi
total_harga?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
2. Fungsi Agregat SUM
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
3. Fungsi Agregat MAX
Digunakan untuk menampilkan nilai tertinggi dari suatu kolom.
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
3. Fungsi Agregat MAX
Example:
Bagaimana cara menampilkan harga tertinggi dari kolom harga
dan ditampilkan dengan nama kolom harga_tertinggi?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
3. Fungsi Agregat MAX
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
3. Fungsi Agregat MAX
Bagaimana untuk menampilkan harga tertinggi untuk tahun
2013?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
3. Fungsi Agregat MAX
Bagaimana untuk menampilkan harga tertinggi untuk tahun
2013 dan ditampilkan dengan nama harga_tertinggi?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
3. Fungsi Agregat MAX
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
4. Fungsi Agregat MIN
Digunakan untuk menampilkan nilai terendah dari suatu kolom
Example:
Bagaimana untuk menampilkan nilai terendah dengan nama
kolom harga_terendah?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
4. Fungsi Agregat MIN
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
4. Fungsi Agregat MIN
Bagaimana menampilkan harga terendah pad atahun 2013?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
4. Fungsi Agregat MIN
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
5. Fungsi Agregat AVG
Digunakan untuk menampilkan nilai rata-rata dari suatu kolom.
Bagaimana untuk menampilkan nilai rata rata dari harga dalam
tabel buku dengan nama kolom harga_rerata?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
5. Fungsi Agregat AVG
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
5. Fungsi Agregat AVG
Bagaimana menampilkan rata rata harga pada tahun 2013
dengan nama kolom harga_rerata dari tabel buku?
JENIS FUNGSI AGREGAT
• Example : Implementasi Fungsi Agregat
5. Fungsi Agregat AVG
SUMBER
• Solichin, Achmad. MySQL 5 : Dari Pemula Hingga Akhir. Buku Komputer Gratis. 2010.
• SQL, Basis Data 1, Chapter 2, PENS ITS
• [URL] : http://www.w3schools.com/sql
• [URL] : http://fairuzelsaid.com/
SELECT

More Related Content

Similar to SELECT

matrei perkuliahana tentang SQL Overview.ppt
matrei perkuliahana tentang SQL Overview.pptmatrei perkuliahana tentang SQL Overview.ppt
matrei perkuliahana tentang SQL Overview.ppterlandarmawan2
 
Pertemuan tentang DDL DML dan praktikum system basis data MYSQL
Pertemuan tentang DDL DML dan praktikum system basis data MYSQLPertemuan tentang DDL DML dan praktikum system basis data MYSQL
Pertemuan tentang DDL DML dan praktikum system basis data MYSQLdezavalorant123
 
Slide Transformasi dan Load Data Menggunakan Talend Open Studio
Slide Transformasi dan Load Data Menggunakan Talend Open StudioSlide Transformasi dan Load Data Menggunakan Talend Open Studio
Slide Transformasi dan Load Data Menggunakan Talend Open Studiossuser52d6bf
 
Perintah Dasar MySQL
Perintah Dasar MySQLPerintah Dasar MySQL
Perintah Dasar MySQLguestad850e
 
Laporan praktikum modul 8 (dml part 2)
Laporan praktikum modul 8 (dml part 2)Laporan praktikum modul 8 (dml part 2)
Laporan praktikum modul 8 (dml part 2)Devi Apriansyah
 
Structure query language
Structure query languageStructure query language
Structure query languageRicky Vb
 
file_2013-09-24_11_21_37_WIBOWO_WICAKSONO,_ST.,M.Kom__5._SQL2.ppt
file_2013-09-24_11_21_37_WIBOWO_WICAKSONO,_ST.,M.Kom__5._SQL2.pptfile_2013-09-24_11_21_37_WIBOWO_WICAKSONO,_ST.,M.Kom__5._SQL2.ppt
file_2013-09-24_11_21_37_WIBOWO_WICAKSONO,_ST.,M.Kom__5._SQL2.pptlumaeducation
 
Dasar_Dasar_Perintah_SQL.ppt
Dasar_Dasar_Perintah_SQL.pptDasar_Dasar_Perintah_SQL.ppt
Dasar_Dasar_Perintah_SQL.pptmusahari1
 
Database Introduction - Akses Data dengan SQL Server
Database Introduction - Akses Data dengan SQL ServerDatabase Introduction - Akses Data dengan SQL Server
Database Introduction - Akses Data dengan SQL ServerDudy Ali
 
SQL Query Comparison.pptx
SQL Query Comparison.pptxSQL Query Comparison.pptx
SQL Query Comparison.pptxssuser0c38031
 
Di2k sq lite-command-line
Di2k sq lite-command-lineDi2k sq lite-command-line
Di2k sq lite-command-linefajarnugroho_id
 
Slide 4 pengelompokan_data
Slide 4 pengelompokan_dataSlide 4 pengelompokan_data
Slide 4 pengelompokan_dataBadra Kusuma
 
Penggunaan SUBQUERY SQL SERVER (USING SUBQUERIES)
Penggunaan SUBQUERY SQL SERVER (USING SUBQUERIES)Penggunaan SUBQUERY SQL SERVER (USING SUBQUERIES)
Penggunaan SUBQUERY SQL SERVER (USING SUBQUERIES)difa febri
 
SQL (Structured query language).pptx
SQL (Structured query language).pptxSQL (Structured query language).pptx
SQL (Structured query language).pptxBagusSantoso44
 

Similar to SELECT (20)

matrei perkuliahana tentang SQL Overview.ppt
matrei perkuliahana tentang SQL Overview.pptmatrei perkuliahana tentang SQL Overview.ppt
matrei perkuliahana tentang SQL Overview.ppt
 
Pertemuan tentang DDL DML dan praktikum system basis data MYSQL
Pertemuan tentang DDL DML dan praktikum system basis data MYSQLPertemuan tentang DDL DML dan praktikum system basis data MYSQL
Pertemuan tentang DDL DML dan praktikum system basis data MYSQL
 
Slide Transformasi dan Load Data Menggunakan Talend Open Studio
Slide Transformasi dan Load Data Menggunakan Talend Open StudioSlide Transformasi dan Load Data Menggunakan Talend Open Studio
Slide Transformasi dan Load Data Menggunakan Talend Open Studio
 
Perintah Dasar MySQL
Perintah Dasar MySQLPerintah Dasar MySQL
Perintah Dasar MySQL
 
Dasar-dasar MySQL
Dasar-dasar MySQLDasar-dasar MySQL
Dasar-dasar MySQL
 
Laporan praktikum modul 8 (dml part 2)
Laporan praktikum modul 8 (dml part 2)Laporan praktikum modul 8 (dml part 2)
Laporan praktikum modul 8 (dml part 2)
 
Structure query language
Structure query languageStructure query language
Structure query language
 
Oracle sql
Oracle sqlOracle sql
Oracle sql
 
Bab 6. SQL
Bab 6. SQLBab 6. SQL
Bab 6. SQL
 
file_2013-09-24_11_21_37_WIBOWO_WICAKSONO,_ST.,M.Kom__5._SQL2.ppt
file_2013-09-24_11_21_37_WIBOWO_WICAKSONO,_ST.,M.Kom__5._SQL2.pptfile_2013-09-24_11_21_37_WIBOWO_WICAKSONO,_ST.,M.Kom__5._SQL2.ppt
file_2013-09-24_11_21_37_WIBOWO_WICAKSONO,_ST.,M.Kom__5._SQL2.ppt
 
Dasar_Dasar_Perintah_SQL.ppt
Dasar_Dasar_Perintah_SQL.pptDasar_Dasar_Perintah_SQL.ppt
Dasar_Dasar_Perintah_SQL.ppt
 
Database Introduction - Akses Data dengan SQL Server
Database Introduction - Akses Data dengan SQL ServerDatabase Introduction - Akses Data dengan SQL Server
Database Introduction - Akses Data dengan SQL Server
 
As400
As400As400
As400
 
SQL Query Comparison.pptx
SQL Query Comparison.pptxSQL Query Comparison.pptx
SQL Query Comparison.pptx
 
Pengantar SQL
Pengantar SQLPengantar SQL
Pengantar SQL
 
Di2k sq lite-command-line
Di2k sq lite-command-lineDi2k sq lite-command-line
Di2k sq lite-command-line
 
Slide 4 pengelompokan_data
Slide 4 pengelompokan_dataSlide 4 pengelompokan_data
Slide 4 pengelompokan_data
 
Materi sql server 3 eresha
Materi sql server 3 ereshaMateri sql server 3 eresha
Materi sql server 3 eresha
 
Penggunaan SUBQUERY SQL SERVER (USING SUBQUERIES)
Penggunaan SUBQUERY SQL SERVER (USING SUBQUERIES)Penggunaan SUBQUERY SQL SERVER (USING SUBQUERIES)
Penggunaan SUBQUERY SQL SERVER (USING SUBQUERIES)
 
SQL (Structured query language).pptx
SQL (Structured query language).pptxSQL (Structured query language).pptx
SQL (Structured query language).pptx
 

More from Erliyan Redy Susanto (9)

perancangan sistem
perancangan sistemperancangan sistem
perancangan sistem
 
normalisasi
normalisasinormalisasi
normalisasi
 
Database Modelling
Database ModellingDatabase Modelling
Database Modelling
 
Komponen sistem database
Komponen sistem databaseKomponen sistem database
Komponen sistem database
 
Database
DatabaseDatabase
Database
 
Sistem Informasi di Dalam Perusahaan
Sistem Informasi di Dalam PerusahaanSistem Informasi di Dalam Perusahaan
Sistem Informasi di Dalam Perusahaan
 
Mengelola perusahaan digiital
Mengelola perusahaan digiitalMengelola perusahaan digiital
Mengelola perusahaan digiital
 
Dokumen Persyaratan Perangkat Lunak
Dokumen Persyaratan Perangkat LunakDokumen Persyaratan Perangkat Lunak
Dokumen Persyaratan Perangkat Lunak
 
Sms gateway bu endang
Sms gateway bu endangSms gateway bu endang
Sms gateway bu endang
 

SELECT

  • 1. S E L E C T h t t p : / / s p a d a . t e k n o k r a t . a c . i d
  • 2. SQL – OPERATOR ARITMATIKA • Pada ekspresi SQL dengan tipe data Number dan Date dapat digunakan operator aritmatika. Operator Precedence Deskripsi + Tambah - Kurang * Kali / Bagi
  • 3. SQL – OPERATOR ARITMATIKA • Contoh: (jika memiliki kolom pada tabel employees) seperti di bawah ini
  • 4. SQL – OPERATOR ARITMATIKA • Contoh: Jika menggunakan statement : SELECT LAST_NAME, SALARY, SALARY+300 FROM EMPLOYEES;
  • 5. SQL – OPERATOR ARITMATIKA • Contoh: (Hasil)
  • 6. SQL – OPERATOR ARITMATIKA • Contoh: (Hasil)
  • 7. SQL – OPERATOR ARITMATIKA • Contoh 2 : (Jika menggunakan dua operator sekaligus) SELECT LAST_NAME, SALARY, 12*SALARY+100 FROM EMPLOYEES; SELECT LAST_NAME, SALARY, 12*(SALARY+100) FROM EMPLOYEES;
  • 8. SQL – OPERATOR ARITMATIKA • Contoh 2 : Hasil Statement 1
  • 9. SQL – OPERATOR ARITMATIKA • Contoh 2 : Hasil Statement 2
  • 10. SQL – OPERATOR ARITMATIKA • Contoh 2 : Hasil Berbeda karena USING PARENTHESES
  • 12. SQL – ALIASES • SQL aliases are used to temporarily rename a table or a column heading. • SQL aliases are used to give a database table, or a column in a table, a temporary name. • Basically aliases are created to make column names more readable.
  • 13. SQL – ALIASES • SQL Alias Syntax for Columns SELECT column_name AS alias_name FROM table_name;
  • 14. SQL – ALIASES • Contoh: Kasus 1 • (Jika ingin membuat last_name menjadi name, dan commission_pct menjadi comm)
  • 15. SQL – ALIASES • Contoh: SELECT last_name AS name, commission_pct AS comm FROM employees;
  • 16. SQL – ALIASES • Contoh: Hasil (Jika ingin membuat last_name menjadi name, dan commission_pct menjadi comm)
  • 17. SQL – ALIASES • Contoh 2: Kasus 2 • (Jika ingin membuat last_name menjadi name, dan kolom salary dikalikan 12 menjadi Annual Salary)
  • 18. SQL – ALIASES • Contoh 2: (Jika ingin membuat last_name menjadi name, dan kolom salary dikalikan 12 menjadi Annual Salary) SELECT last_name “Name”, salary*12 “Annual Salary” FROM employees;
  • 19. SQL – ALIASES • Contoh 2: Hasil (Jika ingin membuat last_name menjadi name, dan kolom salary dikalikan 12 menjadi Annual Salary)
  • 20. SQL – ALIASES • SQL Alias Syntax for Tables SELECT column_name(s) FROM table_name AS alias_name;
  • 21. SQL – ALIASES • Contoh for Table Columns: • The following SQL Statement selects all the orders from the Customer with CustomerID=4 (Around the Horn). • We use the “Customers” and “Orders” tables, and give them tables aliases of “c” and “o” respectively (Here we have used aliases to make the SQL shorter).
  • 22. SQL – ALIASES • Tabel Customers CustomerI D CustomerNam e ContactNam e Address City PostalCode Country 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
  • 23. SQL – ALIASES • Tabel Orders OrderID CustomerID EmployeeID OrderDate ShipperID 10354 58 8 1996-11-14 3 10355 4 6 1996-11-15 1 10356 86 6 1996-11-18 2
  • 24. SQL – ALIASES • Contoh Statement: (with aliases) SELECT o.OrderID, o.OrderDate, c.CustomerName FROM Customers AS c, Orders AS o WHERE c.CustomerName="Around the Horn" AND c.CustomerID=o.CustomerID;
  • 25. SQL – ALIASES • Contoh Statement: (without aliases) SELECT Orders.OrderID, Orders.OrderDate, Customers.CustomerName FROM Customers, Orders WHERE Customers.CustomerName="Around the Horn" AND Customers.CustomerID=Orders.CustomerID;
  • 27. SQL SELECT DISTINCT • The SELECT DISTINCT statement is used to return only distinct (diferent) values. • In a table, a column may contain many duplicate values; and sometimes you only want to list the different (distinct) values. • The DISTINCT keyword can be used to return only distinct (different) values.
  • 28. SQL SELECT DISTINCT • SQL SELECT DISTINCT Syntax SELECT DISTINCT column_name, column_name FROM table_name;
  • 29. SQL SELECT DISTINCT • Contoh : (Kasus 1)
  • 30. SQL SELECT DISTINCT • Contoh : (Kasus 2) • The following SQL statement selects only the distinct values from the "City" columns from the "Customers" table
  • 31. SQL SELECT DISTINCT • Contoh : (Kasus 2) Tabel Customer CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
  • 32. SQL SELECT DISTINCT • Contoh : (Kasus 2) SELECT DISTINCT City FROM Customers;
  • 33. SQL – Operasi Pembanding
  • 34. SQL – OPERATOR PEMBANDING • Berikut ini Operator pembanding dalam SQL Operator Meaning = Equal to > Greater than >= Greater than or Equal to < Less than <= Less than or equal to <> Not Equal to
  • 35. SQL – OPERATOR PEMBANDING • Contoh: (Jika ingin menampilkan salary kurang dari sama dengan 3000 Last_name salary Matos 2600 Vargas 2500 Jose 3100 Santos 3500 Marquez 3100
  • 36. SQL – OPERATOR PEMBANDING • Contoh: Statement SELECT last_name, salary FROM employees WHERE salary <= 3000;
  • 37. SQL – OPERATOR PEMBANDING • Contoh: Hasil
  • 38. SQL – OPERATOR PEMBANDING • Operator Pembanding Kondisi lainnya (Other Comparison Conditions) Operator Meaning BETWEEN … AND …. Between two values (inclusive) IN (set) Match any of a list of values LIKE Match a character pattern IS NULL Is a null value
  • 40. SQL – OPERATOR PEMBANDING • The SQL BETWEEN Operator • The BETWEEN operator selects values within a range. • The values can be numbers, text, or dates.
  • 41. SQL – OPERATOR PEMBANDING • The SQL BETWEEN Syntax SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;
  • 42. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Below is a selection from the ‘Products’ table ProductI D ProductName SupplierID CategoryI D Unit Price 1 Chais 1 1 10 boxes x 20BAGS 18 2 Chang 1 1 24 - 12 oz bottles 19 3 Aniseed Syrup 1 2 12 - 550 ml bottles 10 4 Chef Anton's Cajun Seasoning 1 2 48 - 6 oz jars 22
  • 43. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Kasus : • The following SQL statement selects all products with a price BETWEEN 10 and 20
  • 44. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Answer: SELECT * FROM Products WHERE Price BETWEEN 10 AND 20;
  • 45. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Kasus : • Bagaimana untuk menampilkan products diluar dari range 10 dan 20 ??
  • 46. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Answer: SELECT * FROM Products WHERE Price NOT BETWEEN 10 AND 20;
  • 47. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Kasus : • The following SQL statement selects all products with a price BETWEEN 10 and 20, but products with a CategoryID of 1,2, or 3 should not be displayed?
  • 48. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Answer: SELECT * FROM Products WHERE (Price BETWEEN 10 AND 20) AND NOT CategoryID IN (1,2,3);
  • 49. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Kasus: • The following SQL statement selects all products with a ProductName beginning with any of the letter BETWEEN ‘C’ and ‘M’?
  • 50. SQL – OPERATOR PEMBANDING • Example of The SQL BETWEEN • Answer: SELECT * FROM Products WHERE ProductName BETWEEN 'C' AND 'M';
  • 52. SQL IN • The IN operator allows you to specify multiple values in a WHERE clause. • SQL IN Syntax SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...);
  • 53. SQL IN • Example : Below is a selection from the ‘Customers’ table CustomerI D CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 5 Berglunds snabbköp Christina Berguvsvägen 8 Luleå S-958 22 Sweden
  • 54. SQL IN • Case: • The Following SQL Statement selects all customers with a City of ‘London’ or ‘Berlin’?
  • 55. SQL IN • Answer: SELECT * FROM Customers WHERE City IN ('London‘, ‘Berlin’);
  • 57. SQL LIKE • The LIKE operator is used in a WHERE clause to search for a specified patern in a column. • Gunakan kondisi LIKE untuk melakukan pencarian sebagian nilai string. • Kondisi pencarian dapat menggunakan symbol karakter berikut: • % : Menunjukkan nol/kosong atau sembarang beberapa karakter. • _ : menunjukkan sembarang 1 karakter
  • 58. SQL LIKE • The SQL LIKE Syntax SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern;
  • 60. SQL LIKE • Example: • Kasus 1: • Bagaimana menampilkan first_nama yang memiliki huruf depan S?
  • 62. SQL LIKE • Example: • Kasus 2 • Bagaimana menampilkan nama terakhir yang huruf keduanya mengandung huruf o?
  • 64. SQL LIKE • Exercise: CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden
  • 65. SQL LIKE • Exercise: 1. How to selects all customers with a City starting with the letter “s”? 2. How to selects all customers with a City ending with the letter “s”? 3. How to selects all customers with a Country containing the pattern “land”? 4. How to selects all customers with Country NOT containing the
  • 66. SQL – USING THE NULL CONDITIONS • Example:
  • 68. LOGICAL CONDITIONS • The AND, OR, & NOT operators are used to filter records based on more than one condition. Operator Arti AND Returns TRUE, jika kedua kondisi adalah TRUE OR Returns TRUE, jika salah satu kondisi adalah TRUE NOT Returns TRUE, jika kondisi tersebut adalah False
  • 69. LOGICAL CONDITIONS • The SQL AND & OR Operators • The AND operator display a record if both the first condition AND the second condition are true. • The OR operator displays a record if either the first condition OR the second condition is true.
  • 70. LOGICAL CONDITIONS • Example : Below is a selection from the “Customers” table Custo merID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden
  • 71. LOGICAL CONDITIONS • Example : • Kasus 1 • How to Selects all customers from country “Germany” AND the city “Berlin”, in the Customers table?
  • 72. LOGICAL CONDITIONS • Example : • Answer 1 SELECT * FROM Customers WHERE Country='Germany' AND City='Berlin';
  • 73. LOGICAL CONDITIONS • Example : • Kasus 2 • How to selects all customers from the city ‘Berlin” OR “Munchen”, in the Customers table?
  • 74. LOGICAL CONDITIONS • Example : • Answer 2 SELECT * FROM Customers WHERE City='Berlin' OR City='München';
  • 75. LOGICAL CONDITIONS • Example 3: • Kasus 3 • How to selects all customers from the country “Germany” AND the city must be equal to “Berlin” OR “Munchen”, in the Customers table?
  • 76. LOGICAL CONDITIONS • Example 3: • Answer 3 SELECT * FROM Customers WHERE Country='Germany' AND (City='Berlin' OR City='München');
  • 77. LOGICAL CONDITIONS • Using the NOT Operator
  • 79. SQL – OPERASI PEMBANDING • Rules of Precedence Order Evaluated Operators 1 Arithmetic Operators 2 Concatenation operator 3 Comparison conditions 4 IS [NOT] NULL, LIKE, [NOT] IN 5 [NOT] BETWEEN 6 NOT logical condition 7 AND logical condition 8 OR logical condition
  • 80. SQL – OPERASI PEMBANDING • Example of Rules of Precedence
  • 81. SQL – OPERASI PEMBANDING • Example of Rules of Precedence
  • 83. FUNGSI AGREGAT • Fungsi Agregat dalam SQL adalah fungsi yang menerima kumpulan atau koleksi dan mengembalikan nilai tunggal sebagai hasilnya, seperti: Jumlah data, nilai minimum, nilai maximum dan nilai rata-rata. • Fungsi ini digunakan bersama dengan pernyataan SELECT.
  • 84. JENIS FUNGSI AGREGAT • Standar ISO mendefinisikan lima jenis fungsi agregat, yaitu: Fungsi Penjelasan SUM Digunakan untuk menghitung total nilai dari kolom tertentu COUNT Digunakan untuk menghitung jumlah record AVG Digunakan untuk menampilkan nilai rata-rata dari suatu kolom MAX Digunakan untuk menampilkan nilai tertinggi dari suatu kolom MIN Digunakan untuk menampilkan nilai terendah dari suatu
  • 85. JENIS FUNGSI AGREGAT • Example : • Berikut ini adalah latihan dalam menggunakan fungsi agregat. • Buatlah tabel buku dengan struktur tabel sebagai berikut : -> Next Slide
  • 87. JENIS FUNGSI AGREGAT • Example : Kita lihat deskripsi dari tabel buku.
  • 88. JENIS FUNGSI AGREGAT • Example : Masukkan data sebagai berikut
  • 89. JENIS FUNGSI AGREGAT • Example : Jika ditampilkan dari tabel buku mysql> SELECT * FROM buku; +-----------+------------------------+------------------+---------------+-------+-----------+------+----------------+ | kode_buku | judul_buku | pengarang | penerbit | tahun | kategori | harga| tgl_inventaris | +-----------+------------------------+------------------+---------------+-------+-----------+------+----------------+ | B0001 | Harry Potter | JK Rowling | British Press | 2013 | Fiksi | 50000| 2015-03-01 | | B0002 | Sistem Basis Data | Abdul Kadir | Andi Offset | 2013 | Buku Teks | 40000| 2015-03-01 | | B0003 | Sistem Basis Data | Fathansyah | ITB Press | 2013 | Buku Teks | 30000| 2015-03-01 | | B0004 | Prophet Muhammad | Amir Abdullah | Madina Press | 2014 | Biografi | 45000| 2015-03-01 | | B0005 | Ketika Cinta Bertasbih | Habiburahaman ES | Madina Press | 2014 | Fiksi | 75000| 2015-02-01 | | B0006 | Pemrograman Basis Data | Abdul Kadir | Andi Offset | 2015 | Buku Teks | 67000| 2015-02-01 | +-----------+------------------------+------------------+---------------+-------+-----------+------+----------------+
  • 90. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 1. Fungsi COUNT Digunakan untuk menghitung jumlah record. Example: Bagaimana menghitung jumlah jenis buku di dalam tabel buku?
  • 91. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 1. Fungsi COUNT
  • 92. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 1. Fungsi COUNT Bagaimana cara menghitung jumlah record tabel buku dengan nama kolom jum_rec?
  • 93. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 1. Fungsi COUNT
  • 94. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 1. Fungsi COUNT Bagaimana menghitung jumlah record untuh tahun 2013 yang diberi nama jum_rec?
  • 95. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 1. Fungsi COUNT
  • 96. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 2. Fungsi Agregat SUM Fungsi SUM digunakan untuk menghitung total nilai dari kolom tertentu.
  • 97. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 2. Fungsi Agregat SUM Bagaiamana untuk menghitung total harga dari kolom harga dengan nama kolom menjadi total_harga?
  • 98. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 2. Fungsi Agregat SUM
  • 99. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 2. Fungsi Agregat SUM Bagaimana untuk menghitung total harga untuk tahun 2013 dari kolom kolom harga dengan nama kolom menjadi total_harga?
  • 100. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 2. Fungsi Agregat SUM
  • 101. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 3. Fungsi Agregat MAX Digunakan untuk menampilkan nilai tertinggi dari suatu kolom.
  • 102. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 3. Fungsi Agregat MAX Example: Bagaimana cara menampilkan harga tertinggi dari kolom harga dan ditampilkan dengan nama kolom harga_tertinggi?
  • 103. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 3. Fungsi Agregat MAX
  • 104. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 3. Fungsi Agregat MAX Bagaimana untuk menampilkan harga tertinggi untuk tahun 2013?
  • 105. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 3. Fungsi Agregat MAX Bagaimana untuk menampilkan harga tertinggi untuk tahun 2013 dan ditampilkan dengan nama harga_tertinggi?
  • 106. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 3. Fungsi Agregat MAX
  • 107. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 4. Fungsi Agregat MIN Digunakan untuk menampilkan nilai terendah dari suatu kolom Example: Bagaimana untuk menampilkan nilai terendah dengan nama kolom harga_terendah?
  • 108. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 4. Fungsi Agregat MIN
  • 109. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 4. Fungsi Agregat MIN Bagaimana menampilkan harga terendah pad atahun 2013?
  • 110. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 4. Fungsi Agregat MIN
  • 111. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 5. Fungsi Agregat AVG Digunakan untuk menampilkan nilai rata-rata dari suatu kolom. Bagaimana untuk menampilkan nilai rata rata dari harga dalam tabel buku dengan nama kolom harga_rerata?
  • 112. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 5. Fungsi Agregat AVG
  • 113. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 5. Fungsi Agregat AVG Bagaimana menampilkan rata rata harga pada tahun 2013 dengan nama kolom harga_rerata dari tabel buku?
  • 114. JENIS FUNGSI AGREGAT • Example : Implementasi Fungsi Agregat 5. Fungsi Agregat AVG
  • 115. SUMBER • Solichin, Achmad. MySQL 5 : Dari Pemula Hingga Akhir. Buku Komputer Gratis. 2010. • SQL, Basis Data 1, Chapter 2, PENS ITS • [URL] : http://www.w3schools.com/sql • [URL] : http://fairuzelsaid.com/