01 November 2010

9.5 SQL Having

SQL HAVING clause ditambahkan ke SQL karena kata kunci WHERE tidak dapat digunakan dengan aggregate functions.
Format:
SELECT namakolom1, aggregate_function(namakolom2)
FROM namatabel
WHERE namakolom1 operator nilaikolom1
GROUP BY namakolom1
HAVING aggregate_function(namakolom2) operator nilaikolom2

Contoh penggunaan:
SELECT kodesub, avg(hargajual) as ratarata FROM produk group by kodesub having avg(hargajual) > 30000




  

0 comments: