assignment 3 ORACLE
assignment 3 ORACLE
Highest_prod_price
1499708
2) Display the lowest product price for company name Ashok Leyland.
Highest_prod_price
536129
3) Display the result from customer_details table Whose first name starts with H/h and while
displaying the result add 4 month in purchase date.
Customer_details
Cust_id First_name Last_name Product_id Quantity Purchase_date
5007 Hannah Dyer 2017 1 23-Nov-2001
5008 Heather Edmunds 2018 3 24-Nov-2001
5020 Heather Edmunds 1008 1 5-dec-2008
5021 Heather Edmunds 2024 1 6-dec-2008
5022 Heather Edmunds 2025 2 7-dec-2008
4) Find out the customer details whose first name starts with E or I and last name ends with r or s
and it may in any of the case(Capital/Small).
Note: Name can be any of case. Like(Grace, gRacE, grACe) it should be return.
7) Write a query to get customer details whose last name is having more than 7 character and 5th
character is u/U.
Note: First character of first name in capital letter and last name together.
Customer_name
E Cornish
F Davidson
F Davies
F Dickens
G Dowd
G Duncan
9) Write a query to get customer details whose product_id or quantity is having null value.
10) List out the customer details who has purchase the vehicle in 2008 year.
11) Display the average product id from customer details who has purchase the vehicle in AUGUST
month.
12) Write a query to get difference between highest product price and lowest product price from
product_details table.
14) Write a query to get customer details whose purchase year not equal to 2008,1995,2001.
16) Write a syntax to create tables with primary key on two columns,
And Foreign key with ON DELETE SET NULL and ON DELETE CASCADE constraints.
Also write down point wise difference between Primary key, Unique key and Foreign key
constraints.
17) Write a query to get first not null value consider the following input.
Customer_name
E Cornish
Faith
Davies
F Dickens
G Dowd
Duncan
18) Write a query to concatenate all the first_name,last_name and month name of purchase date
from customer details table. output should be as below.
19) Write query to get total number of quantity sold in July 2001.
20) Write a query to get total number of records are there for Quantity column with null value and
without null values.
21) Write a query to display difference between current date and purchase date in years.
22) Write a query to get all product details with grade of product price as below.
Product Details
Product_id Company_name Product_type Product_name Prod_price Product_grade
1001 Ashok Leyland Bus 12M 744643 C Grade
1002 Ashok Leyland Bus 12M FESLF 1346136 A Grade
1003 Ashok Leyland Bus Viking 879128 C Grade
1004 Ashok Leyland Bus Cheetah 713266 C Grade
23) Write a query to display on which day customer has purchase the product.
Customer_Details
Cust_id First_name Last_name Product_id Quantity Purchase_date Purchase_day
5001 Emma Cornish 1001 1 17-Jul-1995 Monday
5002 Faith Davidson 1001 2 18-Jul-1995 Tuesday
5003 Felicity Davies 1013 1 19-Jul-1995 Wednesday
5004 Fiona Dickens 1014 Null 20-Jul-1995 Thursday
5005 Gabrielle Dowd 1015 1 21-Jul-2001 Friday
Note: Only display 2nd,4th,6th,….. Records from customer details table.(Use ROWNUM).
28) Write a query to add 10 units in quantity and if quantity is null then it should be 10 only as
below.
Input Output
Quantity Updated Quantity
1 11
2 12
1 11
null 10
1 11
null 10
1 11
3 13
29) How to remove extra spaces from left and right side of first name column.
31) Write a query to replace 4th character with same character but 2 times as below.
First_name First_name
Emma Emmaa
Faith Faitth
Felicity Feliicity
Fiona Fionna
Gabrielle Gabrrielle
Grace Gracce
32) Explain TO_CHAR and TO_DATE functions with the help of examples.
33) Write a query to display customer details who has purchase the product in year 1995 or 2008
and first name should contains the ‘a’ character or 4th character of last name should be ‘s’.
34) Write a query to display records from customer details table who has purchase vehicle in current
month.
Note: like current month is march then who else purchase the vehicle in march.
35) Consider there is table with Date_details with day,Month and Year column insert the values from
Customer_details of Purchse_date column to Date_details as follows.
Prod_Info
Product_Nmae Prod_Price Prod_Price_Grade
12M 744643 Null
12M FESLF 1346136 Null
Viking 879128 Null
Cheetah 713266 Null
Eagle 1499708 Null
Electric Bus 1206710 Null
Freedom 768974 Null
Hawk 628910 Null
Hybus 1058508 Null
Prod_Info
Product_Nmae Prod_Price Prod_Price_Grade
12M 744643 B
12M FESLF 1346136 A
Viking 879128 B
Cheetah 713266 B
Eagle 1499708 A
Electric Bus 1206710 A
Freedom 768974 B
Hawk 628910 B
Hybus 1058508 A