9.4.1 SQL Aggregate Functions

Beberapa aggregate functions:
AVG() – menghitung rata-rata
SELECT avg(hargajual)FROM produk
SELECT kodesub, avg(hargajual)FROM produk GROUP BY kodesub
COUNT() – menghitung jumlah baris
SELECT count(hargajual)FROM produk
SELECT kodesub, count(hargajual)FROM produk GROUP BY kodesub
MAX() – menampilkan nilai terbesar
SELECT max(hargajual)FROM produk
SELECT kodesub, max(hargajual)FROM produk GROUP BY kodesub
MIN() – menampilkan nilai terkecil
SELECT min(hargajual)FROM produk
SELECT kodesub, min(hargajual)FROM produk GROUP BY kodesub
SUM() – menampilkan jumlah nilai
SELECT sum(hargajual)FROM produk
SELECT kodesub, sum(hargajual)FROM produk GROUP BY kodesub

 


Post a Comment

0 Comments