KnowledgeBoat Logo
|

Informatics Practices

Consider the following table BANK. Write commands of SQL for (i) to (v):

Table: BANK

Acct_NoAcct_HolderAcct_typeOpening_BalContact_no
11001AtulSaving50009216245833
11002ManshaCurrent100009466615675
11003RahulCurrent20009416822012
11004MehakSavingNULL7805634056
11005AkshayFixed Deposit500008732216155

(i) Show the details of AccountHolders who have opened a Current Account.

(ii) Display the Account Holder and Contact No. of those who have not deposited any opening balance.

(iii) Display the unique Account type available in the table Bank.

(iv) Display all the details of those Accounts whose Account Holder name’s 2nd character is "a".

(v) Add a new record with the following data.

11006, "Tamanna", "Fixed", 70000, 9255617800

SQL Queries

2 Likes

Answer

(i)

SELECT * 
FROM BANK
WHERE ACCT_TYPE = 'CURRENT';
Output
+---------+-------------+-----------+-------------+------------+
| Acct_No | Acct_Holder | Acct_type | Opening_Bal | Contact_no |
+---------+-------------+-----------+-------------+------------+
|   11002 | Mansha      | Current   |    10000.00 | 9466615675 |
|   11003 | Rahul       | Current   |     2000.00 | 9416822012 |
+---------+-------------+-----------+-------------+------------+

(ii)

SELECT ACCT_HOLDER, CONTACT_NO 
FROM BANK
WHERE OPENING_BAL IS NULL;
Output
+-------------+------------+
| ACCT_HOLDER | CONTACT_NO |
+-------------+------------+
| Mehak       | 7805634056 |
+-------------+------------+

(iii)

SELECT DISTINCT Acct_type 
FROM BANK;
Output
+---------------+
| Acct_type     |
+---------------+
| Saving        |
| Current       |
| Fixed Deposit |
+---------------+

(iv)

SELECT * 
FROM BANK
WHERE Acct_Holder LIKE '_a%';
Output
+---------+-------------+-----------+-------------+------------+
| Acct_No | Acct_Holder | Acct_type | Opening_Bal | Contact_no |
+---------+-------------+-----------+-------------+------------+
|   11002 | Mansha      | Current   |    10000.00 | 9466615675 |
|   11003 | Rahul       | Current   |     2000.00 | 9416822012 |
+---------+-------------+-----------+-------------+------------+

(v)

INSERT INTO BANK
VALUES (11006, 'Tamanna', 'Fixed', 70000, 9255617800);

Answered By

2 Likes


Related Questions