19ec103 - S.shivani Shree

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Topic 3 - OPERATORS

Relation: CUSTOMER

CUST_ID CUST_NAME ACC_NUMBER ACCOUNT_TYPE CURRENT_BALANCE PHONE_NUMBER


C101 Samuel 019531000986 Savings 54500 9865478569
C123 Peterson 019536598741 Joint 4320 9689586987
C136 Patrick 019547896346 Savings 62354 7896895847
C109 Andrew 019547876543 Current 450 9876548652
C105 Logan 019547987213 Joint 8056 7893488111
C125 Caleb 019547843521 Current 68475 8056433265
C126 Emily 019547896021 Savings 32165 9685442683
C103 Gemson 019547876543 Current 5324 9876549652

Description: CUSTOMER
The CUSTOMER relation is described as follows:

FIELD TYPE
CUST_ID VARCHAR(10)
CUST_NAME VARCHAR(20)
ACC_NUMBER INTEGER
ACCOUNT_TYPE VARCHAR(20)
CURRENT_BALANCE INTEGER
PHONE_NUMBER VARCHAR(20)

DATABASE PRE-POPULATION QUERIES:


CREATE TABLE CUSTOMER(CUST_ID VARCHAR(10), CUST_NAME VARCHAR(20),
ACC_NUMBER BIGINT, ACCOUNT_TYPE VARCHAR(20), CURRENT_BALANCE INTEGER,
PHONE_NUMBER VARCHAR(20));
INSERT INTO CUSTOMER VALUES('C101','Samuel', 019531000986, 'Savings', 54500, '9865478569');
INSERT INTO CUSTOMER VALUES('C123', 'Peterson', 019536598741, 'Joint', 4320, '9689586987');
INSERT INTO CUSTOMER VALUES('C136', 'Patrick', 019547896346, 'Savings', 62354,
'7896895847');
INSERT INTO CUSTOMER VALUES('C109', 'Andrew', 019547876543, 'Current', 450, '9876548652');
INSERT INTO CUSTOMER VALUES('C105', 'Logan', 019547987213, 'Joint', 8056, '7893488111');
INSERT INTO CUSTOMER VALUES('C125', 'Caleb', 019547843521, 'Current', 68475, '8056433265');
INSERT INTO CUSTOMER VALUES('C126', 'Emily', 019547896021, 'Savings', 32165, '9685442683');
INSERT INTO CUSTOMER VALUES('C103', 'Gemson', 019547876543, 'Current', 5324, '9876549652');
Questions:
1. Query all the fields of the Customer whose CUST ID is 'C105'.

2. Query a list of ID and Names of all the Customers whose Account Type is 'Current'.

3. Query a list of ID and Account Type of the Customers whose Current Balance is greater than 40000.

4. Write a query to deduct Rs.200 from Current Balance of all the customers.
5. Query all the fields of the Customers whose Account Type is not 'Current'.

6. Query all the fields of the Customers whose Current Balance is less than or equal to 500 and Account

Type is Current.

7. Query a list of ID and Phone Number of the customers whose Name starts with 'P'.
8. Query a list of ID and Names of Customers whose Phone_Number contains '89'.

9. Write a query to display the twice of Current Balance of all the Customers.

10. Query all the fields of the Customer whose Current Balance is 8056.

11. Query a list of customers whose name contains ‘e’ as 2nd character.
12. Query all the fields of the Customer whose Current Balance ranges from 35000 to 65000.

13. Write a query to find the Account type of the customers whose IDs are 'C101','C105' and 'C136'.

14. Query all the fields of the Customer whose Account Type is either 'Savings' or 'Current'.

15. Write a query to increment the Current Balance of all the customers with Rs.300 whose Balance is

less than 6000.

16. Query a list of IDs of the Customer whose Name starts with 'G' and its 3rd character is 'm' and ends
with 'n'.

17. Display the ID and Account Number of the Customers Gemson, Logan and Emily in a single column.

18. Query a list of Name and Current Balance of the Customer whose Name does not end with 'n'.

19. Query all the fields of the Customer whose Account Type is not 'Savings' or 'Joint'.

20. Query all the fields of the Customer whose Name is 6 characters long, where the first two characters
are 'Sa', and the last character is 'l'.

21. Bank has increased the interest rate by 2% for all the customers who is having Joint Account. Write a

query to increase the balance of all the customers as per interest rate.

22. Write a query to Increase the Current Balance of all the Customers with Rs. 1000 whose Current

Balance is more than 50,000 and Account Type is Savings.

23. Query all the fields of the Customer whose Name is 'Samuel' and ID is 'C101' and Phone Number

contains '4'.

24. Query all the fields of the Customer whose Name contains 'le' and Current Balance ranges from

50000 to 70000.
25. Query all the fields of the Customer whose Name contains 'o' as second letter from last and ID’s

'C123','C103' or 'C105'.

26. Query all the fields of the Customer who have negative balance, if Rs.500 is deducted from their

account.

27. Query a list of ID, Account Type and Account Number of all the Customers whose Current balance

ranges from 35000 to 65000 and Name contains 't' as third letter.

28. Query all the fields of the Customer whose IDs are not and C101 and Current Balance is not in the

range 10000 to 70000.

29. Query all the fields of the Customer whose Account Type is not 'Joint' and Name is 5 character long.
30. Write a query to Increment the Current Balance of all the customers with Rs.600 whose Current

Balance does not ranges from 4000 to 9000.

You might also like