Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Fundamental, Desain, dan Implementasi

Presentasi serupa


Presentasi berjudul: "Fundamental, Desain, dan Implementasi"— Transcript presentasi:

1 Fundamental, Desain, dan Implementasi
Pengolahan Database : Fundamental, Desain, dan Implementasi Bagian dua: Perkenalan pada Structured Query Language Bagian kedua

2 Menggunakan MS Access

3 Menggunakan MS Access (Lanjutan)

4 Menggunakan MS Access (Lanjutan)

5 Menggunakan MS Access - Hasil

6 Menggunakan MS SQL Server [SQL Query Analyzer]

7 Menggunakan Oracle [SQL*Plus]

8 Menggunakan Oracle [Quest Software’s TOAD]

9 Menggunakan MySQL [MySQL Command Line Client]

10 Menggunakan MySQL [MySQL Query Browser]

11 Sorting the Results: ORDER BY(Di urutkan dengan)
SELECT * FROM ORDER_ITEM ORDER BY OrderNumber, Price;

12 Sort Order: Ascending and Descending
SELECT * FROM ORDER_ITEM ORDER BY Price DESC, OrderNumber ASC; CATATAN : Urutan standar semacam ini ASC - tidak harus ditentukan .

13 WHERE Clause Options: AND
SELECT * FROM SKU_DATA WHERE Department = 'Water Sports' AND Buyer = 'Nancy Meyers';

14 WHERE Clause Options: OR
SELECT * FROM SKU_DATA WHERE Department = 'Camping' OR Department = 'Climbing';

15 WHERE Clause Options:- IN
SELECT * FROM SKU_DATA WHERE Buyer IN ('Nancy Meyers', 'Cindy Lo', 'Jerry Martin');

16 WHERE Clause Options: NOT IN
SELECT * FROM SKU_DATA WHERE Buyer NOT IN ('Nancy Meyers', 'Cindy Lo', 'Jerry Martin');

17 WHERE Clause Options: Ranges with BETWEEN
SELECT * FROM ORDER_ITEM WHERE ExtendedPrice BETWEEN 100 AND 200;

18 WHERE Clause Options: Kisaran dengan Simbol Matematika
SELECT * FROM ORDER_ITEM WHERE ExtendedPrice >= 100 AND ExtendedPrice <= 200;

19 WHERE Clause Options: LIKE and Wildcards
SQL kunci LIKE dapat dikombinasikan dengan simbol wildcard : SQL 92 Standard ( SQL Server , Oracle , dll ) : _ = Tepat satu karakter % = Setiap set dari satu atau lebih karakter MS Access ( berdasarkan MS DOS ) ? = Tepat satu karakter * = Setiap set dari satu atau lebih karakter

20 WHERE Clause Options: LIKE and Wildcards (Lanjutan)
SELECT * FROM SKU_DATA WHERE Buyer LIKE 'Pete%';

21 WHERE Clause Options: LIKE and Wildcards (Lanjutan)
SELECT * FROM SKU_DATA WHERE SKU_Description LIKE '%Tent%';

22 WHERE Clause Options: LIKE and Wildcards
SELECT * FROM SKU_DATA WHERE SKU LIKE '%2__';

23 Fungsi SQL Built-in Ada 5 Fungsi SQL Built-in: COUNT SUM AVG MIN MAX

24 SQL Built-in Functions (Lanjutan)
SELECT SUM (ExtendedPrice) AS Order3000Sum FROM ORDER_ITEM WHERE OrderNumber = 3000;

25 SQL Built-in Functions (Lanjutan)
SELECT SUM (ExtendedPrice) AS OrderItemSum, AVG (ExtendedPrice) AS OrderItemAvg, MIN (ExtendedPrice) AS OrderItemMin, MAX (ExtendedPrice) AS OrderItemMax FROM ORDER_ITEM;

26 SQL Built-in Functions (Lanjutan)
SELECT COUNT(*) AS NumRows FROM ORDER_ITEM;

27 SQL Built-in Functions (Lanjutan)
SELECT COUNT (DISTINCT Department) AS DeptCount FROM SKU_DATA;

28 Arithmetic in SELECT Statements
SELECT Quantity * Price AS EP, ExtendedPrice FROM ORDER_ITEM;

29 Fungsi String di SELECT Statements
SELECT DISTINCT RTRIM (Buyer) + ' in ' + RTRIM (Department) AS Sponsor FROM SKU_DATA;

30 Kata kunci SQL - GROUP BY
SELECT Department, Buyer, COUNT(*) AS Dept_Buyer_SKU_Count FROM SKU_DATA GROUP BY Department, Buyer;

31 Kata kunci SQL - GROUP BY (Lanjutan)
In general, place WHERE before GROUP BY. Some DBMS products do not require that placement, but to be safe, always put WHERE before GROUP BY. The HAVING operator restricts the groups that are presented in the result. There is an ambiguity in statements that include both WHERE and HAVING clauses. The results can vary, so to eliminate this ambiguity SQL always applies WHERE before HAVING.

32 Kata kunci SQL - GROUP BY (Lanjutan)
SELECT Department, COUNT(*) AS Dept_SKU_Count FROM SKU_DATA WHERE SKU <> GROUP BY Department ORDER BY Dept_SKU_Count;

33 Kata kunci SQL - GROUP BY (Lanjutan)
SELECT Department, COUNT(*) AS Dept_SKU_Count FROM SKU_DATA WHERE SKU <> GROUP BY Department HAVING COUNT (*) > 1 ORDER BY Dept_SKU_Count;

34 Querying Multiple Tables: Subqueries
SELECT SUM (ExtendedPrice) AS Revenue FROM ORDER_ITEM WHERE SKU IN (SELECT SKU FROM SKU_DATA WHERE Department = 'Water Sports'); Catatan : Pernyataan SELECT kedua adalah subquery .

35 Querying Multiple Tables: Subqueries (Lanjutan)
SELECT Buyer FROM SKU_DATA WHERE SKU IN (SELECT SKU FROM ORDER_ITEM WHERE OrderNumber IN (SELECT OrderNumber FROM RETAIL_ORDER WHERE OrderMonth = 'January' AND OrderYear = 2004));

36 Querying Multiple Tables: Joins
SELECT Buyer, ExtendedPrice FROM SKU_DATA, ORDER_ITEM WHERE SKU_DATA.SKU = ORDER_ITEM.SKU;

37 Querying Multiple Tables: Joins (Lanjutan)
SELECT Buyer, SUM(ExtendedPrice) AS BuyerRevenue FROM SKU_DATA, ORDER_ITEM WHERE SKU_DATA.SKU = ORDER_ITEM.SKU GROUP BY Buyer ORDER BY BuyerRevenue DESC;

38 Querying Multiple Tables: Joins (Lanjutan)
SELECT Buyer, ExtendedPrice, OrderMonth FROM SKU_DATA, ORDER_ITEM, RETAIL_ORDER WHERE SKU_DATA.SKU = ORDER_ITEM.SKU AND ORDER_ITEM.OrderNumber = RETAIL_ORDER.OrderNumber;

39 Subqueries <=> Joins
Subqueries dan Joins baik memproses beberapa tabel . Sebuah subquery hanya dapat digunakan untuk mengambil data dari tabel atas . Sebuah Joins dapat digunakan untuk memperoleh data dari sejumlah tabel , termasuk " table top " dari subquery . Dalam Bab 7 , kita akan mempelajari subquery berkorelasi. Subquery dapat melakukan pekerjaan yang tidak mungkin dilakukan Joins

40 David M. Kroenke’s Pengolahan Database Fundamental , Desain , dan Implementasi (10th Edition)
Akhir Presentasi : Bab Dua Bagian Kedua

41


Download ppt "Fundamental, Desain, dan Implementasi"

Presentasi serupa


Iklan oleh Google