SQL Queries 2
SQL Queries 2
Database changed
mysql> select cust_id from depositor union all select cust_id from borrower;
+-------------+
| cust_id |
+-------------+
| 192-83-7465 |
| 677-89-9011 |
| 019-28-3746 |
| 192-83-7465 |
| 019-28-3746 |
| 321-12-3123 |
| 336-66-9999 |
| 182-73-6091 |
| 019-28-3746 |
| 192-83-7465 |
| 677-89-9011 |
| 335-57-7991 |
| 321-12-3123 |
| 963-96-3963 |
| 244-66-8800 |
| 019-28-3746 |
+-------------+
mysql> select cust_id from depositor union select cust_id from borrower;
+-------------+
| cust_id |
+-------------+
| 192-83-7465 |
| 677-89-9011 |
| 019-28-3746 |
| 321-12-3123 |
| 336-66-9999 |
| 182-73-6091 |
| 335-57-7991 |
| 963-96-3963 |
| 244-66-8800 |
+-------------+
mysql> select cust_id from depositor union all select cust_id from borrower;
+-------------+
| cust_id |
+-------------+
| 192-83-7465 |
| 677-89-9011 |
| 019-28-3746 |
| 192-83-7465 |
| 019-28-3746 |
| 321-12-3123 |
| 336-66-9999 |
| 182-73-6091 |
| 019-28-3746 |
| 192-83-7465 |
| 677-89-9011 |
| 335-57-7991 |
| 321-12-3123 |
| 963-96-3963 |
| 244-66-8800 |
| 019-28-3746 |
+-------------+
mysql> select cust_id from depositor where cust_id in (select cust_id from borrower);
+-------------+
| cust_id |
+-------------+
| 192-83-7465 |
| 677-89-9011 |
| 019-28-3746 |
| 192-83-7465 |
| 019-28-3746 |
| 321-12-3123 |
+-------------+
mysql> select cust_id from depositor where cust_id not in (select cust_id from borrower);
+-------------+
| cust_id |
+-------------+
| 336-66-9999 |
| 182-73-6091 |
+-------------+
+-----------+
| cust_name |
+-----------+
| Johnson |
| Hayes |
| Smith |
| Johnson |
| Smith |
| Jones |
+-----------+
+-----------+
| cust_name |
+-----------+
| Lindsay |
| Turner |
+-----------+
+-------------+
| cust_id |
+-------------+
| 192-83-7465 |
| 677-89-9011 |
| 321-12-3123 |
| 336-66-9999 |
| 182-73-6091 |
| 019-28-3746 |
+-------------+
+-------------+-------------+---------+
+-------------+-------------+---------+
+-------------+-------------+---------+
+-------------+
| sum(assets) |
+-------------+
| 32300000 |
+-------------+
+-----------+
| total_sum |
+-----------+
| 32300000 |
+-----------+
+-------------+-------------+---------+
+-------------+-------------+---------+
+-------------+-------------+---------+
+----------+
| count(*) |
+----------+
| 8|
+----------+
+---------------+
| count(assets) |
+---------------+
| 7|
+---------------+
+--------+-------+
| salary | name |
+--------+-------+
| 1000 | Teena |
| 2000 | Meena |
+--------+-------+
| salary | name |
+--------+-------+
| NULL | NULL |
| 2000 | Meena |
+--------+-------+
+----------+
| count(*) |
+----------+
| 2|
+----------+
+---------------+
| count(salary) |
+---------------+
| 1|
+---------------+
+--------------------+---------------+
| count(branch_name) | count(assets) |
+--------------------+---------------+
| 8| 7|
+--------------------+---------------+