Queries On BANK Database
Queries On BANK Database
Queries On BANK Database
mysql> select *
-> from loan
-> order by amount desc, loan_number asc;
+-------------+-------------+--------+
| loan_number | branch_name | amount |
+-------------+-------------+--------+
| L-20 | North Town | 7500 |
| L-23 | Redwood | 2000 |
| L-14 | Downtown | 1500 |
| L-15 | Perryridge | 1500 |
| L-16 | Perryridge | 1300 |
| L-17 | Downtown | 1000 |
| L-11 | Round Hill | 900 |
| L-21 | Central | 570 |
| L-93 | Mianus | 500 |
+-------------+-------------+--------+
9 rows in set (0.00 sec)
mysql>
mysql> select branch_name, avg (balance)
-> from account
-> group by branch_name
-> having avg (balance) > 1200;
Empty set (0.00 sec)
mysql>
mysql> select avg (balance)from account;
+---------------+
| avg (balance) |
+---------------+
| 641.6667 |
+---------------+
1 row in set (0.00 sec)
mysql> select customer_name from depositor where customer_name in(select customer_name from
borrower);
+---------------+
| customer_name |
+---------------+
| Smith |
| Jones |
| Smith |
+---------------+
3 rows in set (0.00 sec)
mysql> select customer_name from depositor where customer_name not in(select customer_name from
borrower);
+---------------+
| customer_name |
+---------------+
| Hayes |
| Johnson |
| Hayes |
| Johnson |
| Lindsay |
| Turner |
| Majeris |
+---------------+
7 rows in set (0.00 sec)