Informatics Practices
Consider the following table BANK. Write commands of SQL for (i) to (v):
Table: BANK
| Acct_No | Acct_Holder | Acct_type | Opening_Bal | Contact_no |
|---|---|---|---|---|
| 11001 | Atul | Saving | 5000 | 9216245833 |
| 11002 | Mansha | Current | 10000 | 9466615675 |
| 11003 | Rahul | Current | 2000 | 9416822012 |
| 11004 | Mehak | Saving | NULL | 7805634056 |
| 11005 | Akshay | Fixed Deposit | 50000 | 8732216155 |
(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
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);
Related Questions
Find out the errors in the following code snippet and rewrite the code by underlining the corrections made.
30=y for i in range (2, 6) print (true) else: print ("Loop over")Consider the following dictionary and write the answers of the following:
DAYS={"day1": "Sunday", "day2": "Monday", "day3":"Tuesday", 'day5':" Thursday"}(a) Add 'Wednesday' to the dictionary DAYS as a key 'day4'.
(b) Remove 'day5' item from the dictionary.
(c) Given the Dictionary metal, what is the output generated by the following code:
metal={"first":"gold", "second":"silver", "first":"copper"} print(metal)Write a program to accept a number from the user and check whether it is a prime number or not.
Mr. Malhotra is working on a MySQL table named Stud with the following table schema:
Field Type Null Key Default Extra regno int NO PRI NULL name varchar(30) YES NULL marks int YES 0 dob date NO NULL (i) Which command is used to get the given table schema as output?
(ii) Write the query to create table Stud.
(iii) Write a command to add a column address varchar(20) in table Stud.
(iv) Write a command to delete the column dob from the table Stud.
(v) Can Mr. Malhotra create more than one table in a database?