Professional Documents
Culture Documents
• Aggregate function
• Grouping Data
• HAVING
• Subqueries
• Relational Set Operators
• MIN and MAX functions help to find the highest and lowest value
from an attribute
• The MIN and MAX function can also be used with date columns
• Syntax
• SUM function computes the total sum for any specified numeric
attribute, using any condition(s)
• Syntax
• Rows can be grouped into smaller collection quickly and easily using
GROUP BY clause
• Syntax
SELECT columnlist
FROM tablelist
[WHERE conditionlist ]
[GROUP BY columnlist ]
[ORDER BY columnlist [ASC | DESC] ];
• HAVING clause is used because the WHERE keyword cannot be used with
aggregate functions
• This is because the WHERE clause is execute before GROUP BY
• Syntax
SELECT columnlist
FROM tablelist
[WHERE conditionlist ]
[GROUP BY columnlist ]
[HAVING conditionlist ]
[ORDER BY columnlist [ASC | DESC] ];
• Example:
• Suppose that you want to generate a listing of the number of products in
the inventory supplied by each vendor
• However, this time you want to limit the listing to products whose prices average
less than $10
• The query
1. Tampilkan desc tugas, nama mata kuliah, dan nama dosen dari
tugas yang paling banyak dikerjakan oleh mahasiswa
2. Tampilkan nama mata kuliah dan nama dosen yang memiliki
paling banyak jenis tugas
3. Tampilkan desc tugas, nama mata kuliah dan nama dosen dari
tugas yang memiliki rata-rata nilai 70 sampai 80
4. Tampilkan nama mahasiswa, NRP, dan nilai yang memiliki nilai
dibawah rata-rata pada tugas ‘%car%’.
5. Tampilkan desc tugas, nama mata kuliah dan nama dosen yang
memiliki nilai rata-rata dibawah rata-rata nilai semua tugas