DRISHTI AGARWAL
Field Data Constrain Description
type t
Accno NUMER(4) PRIMARY KEY Account number
Bname VARCHAR(15) NOT NULL Bank name
Cname VARCHAR(25) NOT NULL Customer name
LAmount NUMBER(8,2) Loan amount
Installement NUMBER(3) Total number of
s instalments
Irate NUMBER(5,2) DEFAULT8.0 Interest rate
ISDate Date Interest starting date
Consider a table FINANCE with the following data types and data
Structure of table: FINANCE
Data in table:FINANCE
Accno Bname Cname LAmount Instalments IRate ISdate
1 SBI Vikash Rai 750000 142 12.00 2011-07-19
2 ICICI Milkha 1580000 252 10.00 2010-03-22
Singh
3 PNB Binod Goel 530000 140 NULL 2012-03-08
4 SBI [Link] 850000 165 10.00 2011-06-12
5 OBC P.N sinha 1200000 210 12.50 2011-01-03
6 ICICI [Link] 1700000 154 12.50 2009-06-05
r
7 HDFC [Link] 1500000 190 NULL 2010-03-05
Write SQL query commands for the following
questions:
XII -F
DRISHTI AGARWAL
Create Table/Insert Into:
1. Create the table FINANCE
2. Display the structure of the table FINANCE.
3. Insert records/tuples in it.
XII -F
DRISHTI AGARWAL
Simple SELECT query questions:
4. Display the details of all the rows from
FINANCE table.
5. Display the rows containing AccNo,
Bname, Cname, and LAmount columns.
Conditional SELECT query using
WHERE Clause:
6. Display the details of all the finance
records whose instalment is less than
200.
XII -F
DRISHTI AGARWAL
7. Display the Accno, Cname and
LAmount of all the records which started
before '2011-01-01
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
8. Display the Accno, Cname and
LAmount of all the finance records whose
interest rate is more than and equal to
10.00.
SELECT query Using NULL
9. Display the details of all the loans
whose rate of interest is NULL
10 Display the details of all the loans
whose rate of interest is not NULL
SELECT query Using DISTINCT
Clause:
11. Display the name of banks who
finance various loans from the table
FINANCE.
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
12. Display the different interest rates that
banks are charging for various loans
excluding NULL
SELECT query using Logical
Operators (NOT, AND, OR)
13. Display the details of all the finance
amount which started after 2010-12-31
and for which the number of instalments
is more than 150.
XII -F
DRISHTI AGARWAL
14. Display the CName and LAmount for
all those records for which either
instalments are less than 150 or bank
name is SBI
15 Display the CName and LAmount for
all those loans for which the loan amount
is either less than 1200000 or late is more
than 11.50.
XII -F
DRISHTI AGARWAL
16. Display the details of all the loans
which are financed in the year 2009
XII -F
DRISHTI AGARWAL
17. Display the details of all the loans
whose Lamount is in the range 8000000
1500000
18. Display the details of all the loans
whose rate of interest is in the range
11.00 to 12.00
SELECT query using IN Operator:
19 Display the Cust Name and Loan
Amount for all the loans for which the
number of instalments are 140, 165, and
190 (Using IN operator)
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
SELECT query using BETWEEN
Operator:
20. Display the details of all the amounts,
whose LAmount is in the range 800000 to
1500000 (Using BETWEEN operator)
21. Display the details of all the loans
whose rate of interest is in the range
10.00 to 12.00 (Using BETWEEN
operator)
SELECT query using LIKE
Operator:
XII -F
DRISHTI AGARWAL
22. Display the Accno, C. Name, and
LAmount for all the loans for which the
Cust Name ends with Singh
23. Display the Accno, CName, and
LAmount for all the loans for which the
CName ends with "a”.
XII -F
DRISHTI AGARWAL
24 Display the AccNo, Cust _Name, and
Loan_ Amount for all the loans for which
the Cust Name contains “t”.
__
25 Display the Accno,CName, and
LAmount for all the loans for which the
Cust_ Name does not contain ”n”.
XII -F
DRISHTI AGARWAL
26. Display the AccNo, Cust_ Name, and
Loan_ Amount for all the loans for which
the Cust_ Name contains “a” as the
second last character
SELECT query using ORDER BY
clause:
27. Display the details of all the loans in
the ascending order of their LAmount
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
28. Display the details of all the loans in
the descending order of their ISDate.
29 Display the details of all the loans in
the ascending order of their Loan Amount
and within Loan Amount in the
descending order of their Start Date
XII -F
DRISHTI AGARWAL
Using UPDATE, DELETE, ALTER
TABLE:
30 Put the interest rate 11.50 for all the
loans for which the interest rate is NULL
31. Increase the interest rate by 0.2 for all
the loans for which the loan amount is
more than 1000000
32. Delete the records of all the loans
whose start date is before 2007.
XII -F
DRISHTI AGARWAL
[Link] the records of all the loans of ‘K.P. Singh’.
34. Add another column Category of type CHAR(1) in the FINANCE
table.
XII -F
DRISHTI AGARWAL
SELECT query using aggregate
functions:
35. To find the highest loan amount
whose interest rate is 12.70
XII -F
DRISHTI AGARWAL
36. To find customer name and minimum
loan amount which started in year 2011.
37. To find bank name who has highest
Interest rate.
38. To count total number of customers
whose interest rate is NULL;
XII -F
DRISHTI AGARWAL
39. To find total Joan amount financed in
year 2010;
XII -F
DRISHTI AGARWAL
SELECT query using GROUP BY
and HAVING clause:
40. Write a query to bank wise display
total finance amount
41. Write a query to find the maximum
loan amount of each bank that has a
maximum loan amount more than
1000000
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
XII -F
DRISHTI AGARWAL
XII -F