Basisdata Pertanian. After completing this lesson, you should be able to do the following Identify the available group functions Describe the use of group.

Slides:



Advertisements
Presentasi serupa

Advertisements

Pengujian Hipotesis untuk Satu dan Dua Varians Populasi
Algoritma & Pemrograman #10
Mata Kuliah : ALGORITMA dan STRUKTUR DATA 1.
SQL.
PEMOGRAMAN BERBASIS JARINGAN
SQL (Structured Query Language)
SQL (Structured Query Language)
1 Pertemuan > Desain fisik basis data Matakuliah: >/ > Tahun: > Versi: >
SQL Server :: Transact– SQL #1 Laboratorium Perancangan/Pemrograman Basis Data Komposisi oleh Budi Prayitno Februari 2012 Batam.
Wood Balance Data Base Pendekatan Supply and Use Table.
Memanipulasi Data1 III - Memanipulasi Data Memasukkan Data dengan INSERT: –Memasukkan nilai NULL –Menambahkan sejumlah baris data Mengubah Data dengan.
PERULANGANPERULANGAN. 2 Flow of Control Flow of Control refers to the order that the computer processes the statements in a program. –Sequentially; baris.
Praktikum Database Query Tingkat Lanjut Abdul Kadir.
Slide 3-1 Elmasri and Navathe, Fundamentals of Database Systems, Fourth Edition Revised by IB & SAM, Fasilkom UI, 2005 Exercises Apa saja komponen utama.
Database Create-Retrieve-Update-Delete (CRUD)
PROSES PADA WINDOWS Pratikum SO. Introduksi Proses 1.Program yang sedang dalam keadaan dieksekusi. 2.Unit kerja terkecil yang secara individu memiliki.
Review Operasi Matriks
Restricting and Sorting Data
Ekonomi Manajerial dalam Perekonomian Global
SQL Basis Data.
SQL ADVANCEADVANCE. SQL Data Type MySQL Text Type : 9/7/2014By : Suwondo, S.Kom2.
Implementing an REA Model in a Relational Database
2nd MEETING Assignment 4A “Exploring Grids” Assignment 4 B “Redesign Grids” Create several alternatives grid sysytem using the provided elements: (min.
PEMROGRAMAN PPBD (UAS) SEBELUM MELANGKAH KE TAHAP SELANJUTNYA BERDOA DULU BIAR LANCAR DAN GA EROR
SMPN 2 DEMAK GRADE 7 SEMESTER 2
By. Rita Wiryasaputra Daftar Pustaka Panduan Membuat Aplikasi Database dengan PHP, Syafii, Yogyakarta, Andi Offset, 2005 Membangun Website Dinamis dan.
1. 2 Work is defined to be the product of the magnitude of the displacement times the component of the force parallel to the displacement W = F ║ d F.
SQL.
Structured Query Language (SQL)
Web Teknologi I (MKB511C) MINGGU 3 Web Teknologi I (MKB511C) Minggu 3 Page 1 Pokok Bahasan: MySQL Tujuan Instruksional Khusus: Agar mahasiswa dapat mengetahui.
Web Teknologi I (MKB511C) Minggu 12 Page 1 MINGGU 12 Web Teknologi I (MKB511C) Pokok Bahasan: – Text processing perl-compatible regular expression/PCRE.
Made by: Febri, Andrew, Erina, Leon, Luvin, Jordy
PRAKTIKUM BASIS DATA (4) TEKNIK INFORMATIKA UNIVERSITAS MERCU BUANA
Data Manipulation Language (Aggregate Function)
Query Agregasi akhmadzaini.
Jalankan script sql berikut : sekolah.sql
DATA AGREGAT MENGGUNAKAN GROUP FUNCTIONS
SQL 2. Database TRANSACTION Tabel yang terlibat : Customer berisi data pelanggan (nama, alamat, dll) OderInfo berisi info pemesanan oleh pelanggan (tgl.
Fungsi Agregat fungsi yang mengambil suatu kumpulan nilai-nilai sebagai input dan mengembalikan satu nilai sebagai output Select fungsi agregat SUM/AVG/MIN/MAX/COUNT.
SQL.
Data Definition Language dan Data Manipulation Language
Praktikum Database Subquery Lanjutan dan View Abdul Kadir.
MANAJEMEN BASIS DATA Pertemuan 6 SQL - SELECT.
P E R T E M U A N 12 SISTEM BASIS DATA.
SQL-Aggregate dengan Fungsi GROUP, HAVING dan subQuery
SQL: DML (2) Basis Data Pertemuan 07.
Dr. KUSRINI, M.KOM 66. Select * From nama_tabel [Where Kondisi] [Order by Kolom_x] Atau Select Kolom_1,Kolom_2,..Kolom_n From nama_tabel [Where Kondisi]
MANAJEMEN BASIS DATA Pertemuan 8 SUBQUERY.
Data Manipulation Language
PERTEMUAN 10 QUERY KOMERSIAL LANJUTAN Agus Riyanto, S.Kom.
PRAKTIKUM BASIS DATA (4) TEKNIK INFORMATIKA UNIVERSITAS MERCU BUANA
Data Manipulation Language Presented by : Herianto.
SQL (Structure Query Language) Pertemuan 3 – RESTRICTING AND SORTING DATA sy urf gm ail. co m.
SQL (Structure Query Language) Pertemuan 5 – Reporting Aggregate Data Using the Group Function sy urf gm ail. co m.
Cursor MI2163 Dasar Pemrograman Basis Data. Introduction Cursor merupakan suatu variabel yang digunakan untuk menampung hasil query yang terdiri atas.
SQL (Structure Query Language)
Structure Query Language
Query.
Query.
EXIT KD 3.4 “ Fungsi-Fungsi Agregasi “. MATERI Disusun Oleh :
Fundamental, Desain, dan Implementasi
- Modul 5 - Query Lanjut 2/20/2018 7:46 PM
Connect to the Server - Putty
Rekayasa Perangkat Lunak (Materi 2 Database)
MODUL 4 MENAMPILKAN DATA DARI SATU TABEL
SQL (Structured Query Language) Oleh : Cosmas Haryawan.
MODUL 4 MENAMPILKAN DATA DARI SATU TABEL
BASIS DATA LANJUT SEMESTER II
BAHASA BASIS DATA Data Manipulation Languange
Transcript presentasi:

Basisdata Pertanian

After completing this lesson, you should be able to do the following Identify the available group functions Describe the use of group functions Group data by using the GROUP BY clause Include or exclude grouped rows by using the HAVING clause

Group functions operate on sets of rows to give one result per group. EMPLOYEES Maximum salary in EMPLOYEES table

 AVG  COUNT  MAX  MIN  STDDEV  SUM  VARIANCE

SELECT [column,] group_function (column),... FROM table [WHERE condition] [GROUP BY column] [ORDER BY column]; AVG (SALARY)MAX (SALARY)MIN (SALARY)SUM (SALARY)

You can use AVG and SUM for numeric data. SELECT AVG (salary), MAX (salary), MIN (salary), SUM (salary) FROM employees WHERE job_id LIKE '%REP%';

Using the MIN and MAX Functions You can use MIN and MAX for numeric, character, and date data types SELECT MIN (hire_date), MAX (hire_date) FROM employees; MIN (HIRE_MAX (HIRE_ 17-JUN-8729-JAN-00

COUNT(*) returns the number of rows in a table: SELECTCOUNT (*) FROM employees WHERE department_id = 50; SELECTCOUNT (commission_pct) FROM employees WHERE department_id = 80; 1 COUNT(expr) returns the number of rows with non-null values for the expr: 2 COUNT (*) 5 COUNT (commission_pct) 3

Using the DISTINCT Keyword  COUNT(DISTINCT expr) returns the number of distinct non- null values of the expr.  To display the number of distinct department values in the EMPLOYEES table: SELECT COUNT (DISTINCT department_id) FROM employees; COUNT (DISTINCT DEPARTMENT_ID) 7

Kelompok Fungsi dan Nilai Null Kelompok fungsi membiarkan nilai null dalam kolom: SELECT AVG(commission_pct) FROM employees; Fungsi NVL memaksa fungsi kelompok untuk memasukkan Nilai null : SELECT AVG(NVL(commission_pct, 0)) FROM employees; COUNT (DISTINCT DEPARTMENT_ID) COUNT (DISTINCT DEPARTMENT_ID)

EMPLOYEES DEPARTMENT-IDSALARY … 20 baris terpilih DEPARTMENT-IDAVG (SALARY) Average salary in EMPLOYEES table for each department

SELECT column, group_function(column) FROM table [WHERE condition] [GROUP BY group_by_expression] [ORDER BY column]; Anda dapat membagi baris sebuah tabel menjadi kelompok- kelompok yang lebih kecil dengan menggunakan klausa GROUP BY

Semua kolom dalam daftar SELECT yang bukan fungsi kelompok harus dalam klausa GROUP BY. SELECT department_id, AVG(salary) FROM employees GROUP BY department_id ;

GROUP BY kolom tidak harus dalam daftar SELECT. SELECT AVG(salary) FROM employees GROUP BY department_id ; AVG(SALARY)

EMPLOYEES Tambahkan gaji dalam tabel EMPLOYEES untuk setiap pekerjaan, dikelompokkan berdasarkan department

SELECT department_id dept_id, job_id, SUM(salary) FROM employees GROUP BY department_id, job_id ;

Setiap kolom atau ekspresi dalam daftar SELECT yang bukan merupakan fungsi agregat harus dalam klausa GROUP BY: SELECT department_id, COUNT(last_name) FROM employees; SELECT department_id, COUNT(last_name) * ERROR at line 1: ORA-00937: not a single-group group function Column missing in the GROUP BY clause

You cannot use the WHERE clause to restrict groups. You use the HAVING clause to restrict groups. You cannot use group functions in the WHERE clause. SELECT department_id, AVG(salary) FROM employees WHERE AVG(salary) > 8000 GROUP BY department_id; WHERE AVG(salary) > 8000 * ERROR at line 3: ORA-00934: group function is not allowed here Cannot use the WHERE clause to restrict groups

EMPLOYEES … Gaji maksimum per departemen saat itu lebih besar dari $ $10.000

Bila Anda menggunakan klausa HAVING, server Oracle membatasi kelompok sebagai berikut: 1. Baris akan dikelompokkan. 2. Fungsi Kelompok diterapkan. 3. Kelompok yang cocok dengan klausa HAVING ditampilkan. SELECT column, group_function FROM table [WHERE condition] [GROUP BY group_by_expression] [HAVING group_condition] [ORDER BY column];

SELECT department_id, MAX(salary) FROM employees GROUP BY department_id HAVING MAX(salary)>10000 ;

SELECT job_id, SUM(salary) PAYROLL FROM employees WHERE job_id NOT LIKE '%REP%' GROUP BY job_id HAVING SUM(salary) > ORDER BY SUM(salary);

Display the maximum average salary: SELECT MAX(AVG(salary)) FROM employees GROUP BY department_id;

Display the maximum average salary: SELECT MAX(AVG(salary)) FROM employees GROUP BY department_id;

In this lesson, you should have learned how to: Use the group functions COUNT, MAX, MIN, and AVG Write queries that use the GROUP BY clause Write queries that use the HAVING clause SELECT column, group_function FROM table [WHERE condition] [GROUP BY group_by_expression] [HAVING group_condition] [ORDER BY column];