PERINTAH FUNGSI MAX, MIN, COUNT, SUM, & AVG
PERINTAH QUERY FUNGSI MAX, MIN, COUNT, SUM, & AVG DI CMD
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\EDI SANTOSO>cd/xampp/mysql/bin
C:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.8 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use akademik;
Database changed
mysql> show tables;
+--------------------+
| Tables_in_akademik |
+--------------------+
| dosen |
| frs |
| jurusan |
| mahasiswa |
| matkul |
| nilai_uas |
| nilai_uts |
| semester |
+--------------------+
8 rows in set (0.17 sec)
mysql> select*from nilai_uts;
+------------+-------------+------------+------------+-------+
| kode_nilai | kode_matkul | kode_dosen | nim | nilai |
+------------+-------------+------------+------------+-------+
| 1 | 01SDB | 001 | 43A8700613 | 99 |
| 2 | 02BP | 002 | 43A8700614 | 100 |
| 3 | 03ASD | 003 | 43A8700615 | 98 |
| 4 | 04SD | 004 | 43A8700616 | 90 |
| 5 | 05MP | 005 | 43A8700617 | 85 |
+------------+-------------+------------+------------+-------+
5 rows in set (0.03 sec)
BUAT MENCARI NILAI TERTINGGI DI KOLOM NILAI,,DARI TABLE NILAI_UTS
mysql> select max(nilai) from nilai_uts;
+------------+
| max(nilai) |
+------------+
| 100 |
+------------+
1 row in set (0.03 sec)
BUAT MENCARI NILAI TERENDAH DI KOLOM NILAI,,DARI TABLE NILAI_UTS
mysql> select min(nilai) from nilai_uts;
+------------+
| min(nilai) |
+------------+
| 85 |
+------------+
1 row in set (0.00 sec)
BUAT MENJUMLAH KAN BARIS RECORD PADA FIELD DARI TABLE NILAI_UTS
mysql> select count(*) from nilai_uts;
+----------+
| count(*) |
+----------+
| 5 |
+----------+
1 row in set (0.00 sec)
BUAT MENJUMLAH KAN BARIS RECORD DARI TABLE NILAI_UTS DENGAN KONDISI KODE_NILAI=3
mysql> select count(*) from nilai_uts where kode_nilai='3';
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
BUAT MENJUMLAH KAN SEMUA NILAI PADA KOLOM NILAI,,DARI TABEL NILAI_UTS
mysql> select SUM(nilai) from nilai_uts;
+------------+
| SUM(nilai) |
+------------+
| 472 |
+------------+
1 row in set (0.00 sec)
BUAT MENJUMLAH KAN NILAI PADA KOLOM NILAI,,DARI TABEL NILAI_UTS DENGAN KONDISI KODE_NILAI=3
mysql> select SUM(nilai) from nilai_uts where kode_nilai='3';
+------------+
| SUM(nilai) |
+------------+
| 98 |
+------------+
1 row in set (0.00 sec)
BUAT MENCARI RATA-RATA DARI KESELURUHAN NILAI PADA KOLOM NILAI,,DARI TABEL NILAI_UTS
mysql> select AVG(nilai) from nilai_uts;
+------------+
| AVG(nilai) |
+------------+
| 94.4 |
+------------+
1 row in set (0.03 sec)
BUAT MENCARI RATA-RATA DARI KESELURUHAN NILAI PADA KOLOM NILAI,,DARI TABEL NILAI_UTS
mysql> select SUM(nilai)/count(*) from nilai_uts;
+---------------------+
| SUM(nilai)/count(*) |
+---------------------+
| 94.4 |
+---------------------+
1 row in set (0.00 sec)
BUAT MENCARI RATA-RATA SELURUH NILAI PADA KOLOM NILAI DARI TABEL NILAI_UTS DENGAN KONDISI KODE_NILAI=3
mysql> select SUM(nilai)/COUNT(*) from nilai_Uts where kode_nilai='3';
+---------------------+
| SUM(nilai)/COUNT(*) |
+---------------------+
| 98 |
+---------------------+
1 row in set (0.00 sec)
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\EDI SANTOSO>cd/xampp/mysql/bin
C:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.8 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use akademik;
Database changed
mysql> show tables;
+--------------------+
| Tables_in_akademik |
+--------------------+
| dosen |
| frs |
| jurusan |
| mahasiswa |
| matkul |
| nilai_uas |
| nilai_uts |
| semester |
+--------------------+
8 rows in set (0.17 sec)
mysql> select*from nilai_uts;
+------------+-------------+------------+------------+-------+
| kode_nilai | kode_matkul | kode_dosen | nim | nilai |
+------------+-------------+------------+------------+-------+
| 1 | 01SDB | 001 | 43A8700613 | 99 |
| 2 | 02BP | 002 | 43A8700614 | 100 |
| 3 | 03ASD | 003 | 43A8700615 | 98 |
| 4 | 04SD | 004 | 43A8700616 | 90 |
| 5 | 05MP | 005 | 43A8700617 | 85 |
+------------+-------------+------------+------------+-------+
5 rows in set (0.03 sec)
BUAT MENCARI NILAI TERTINGGI DI KOLOM NILAI,,DARI TABLE NILAI_UTS
mysql> select max(nilai) from nilai_uts;
+------------+
| max(nilai) |
+------------+
| 100 |
+------------+
1 row in set (0.03 sec)
BUAT MENCARI NILAI TERENDAH DI KOLOM NILAI,,DARI TABLE NILAI_UTS
mysql> select min(nilai) from nilai_uts;
+------------+
| min(nilai) |
+------------+
| 85 |
+------------+
1 row in set (0.00 sec)
BUAT MENJUMLAH KAN BARIS RECORD PADA FIELD DARI TABLE NILAI_UTS
mysql> select count(*) from nilai_uts;
+----------+
| count(*) |
+----------+
| 5 |
+----------+
1 row in set (0.00 sec)
BUAT MENJUMLAH KAN BARIS RECORD DARI TABLE NILAI_UTS DENGAN KONDISI KODE_NILAI=3
mysql> select count(*) from nilai_uts where kode_nilai='3';
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
BUAT MENJUMLAH KAN SEMUA NILAI PADA KOLOM NILAI,,DARI TABEL NILAI_UTS
mysql> select SUM(nilai) from nilai_uts;
+------------+
| SUM(nilai) |
+------------+
| 472 |
+------------+
1 row in set (0.00 sec)
BUAT MENJUMLAH KAN NILAI PADA KOLOM NILAI,,DARI TABEL NILAI_UTS DENGAN KONDISI KODE_NILAI=3
mysql> select SUM(nilai) from nilai_uts where kode_nilai='3';
+------------+
| SUM(nilai) |
+------------+
| 98 |
+------------+
1 row in set (0.00 sec)
BUAT MENCARI RATA-RATA DARI KESELURUHAN NILAI PADA KOLOM NILAI,,DARI TABEL NILAI_UTS
mysql> select AVG(nilai) from nilai_uts;
+------------+
| AVG(nilai) |
+------------+
| 94.4 |
+------------+
1 row in set (0.03 sec)
BUAT MENCARI RATA-RATA DARI KESELURUHAN NILAI PADA KOLOM NILAI,,DARI TABEL NILAI_UTS
mysql> select SUM(nilai)/count(*) from nilai_uts;
+---------------------+
| SUM(nilai)/count(*) |
+---------------------+
| 94.4 |
+---------------------+
1 row in set (0.00 sec)
BUAT MENCARI RATA-RATA SELURUH NILAI PADA KOLOM NILAI DARI TABEL NILAI_UTS DENGAN KONDISI KODE_NILAI=3
mysql> select SUM(nilai)/COUNT(*) from nilai_Uts where kode_nilai='3';
+---------------------+
| SUM(nilai)/COUNT(*) |
+---------------------+
| 98 |
+---------------------+
1 row in set (0.00 sec)
(y)
BalasHapus