Rdbms Coding
Rdbms Coding
model_name varchar(20),
manufacturer varchar(20),
date_of_manufac date,
warranty_in_years number(10),
price number(7,2),
distributor_id varchar(10),
spec_no varchar(10),
);
sales_date date,
ime_no varchar(10),
price number(10),
discount number(10),
net_amount number(10),
customer_id varchar(10),
Q) ALTER TABLE 2 ( change the name of the table from Sales_Info to Trade_Info)?
Q) Purge Table ( all the records from the "Customer_Info" table. Write an SQL statement to purge all the records from
the Customer_Info table without allowing rollback activity.)?
Q) Try It Out ( order to create the department table using the structure given below, considering the product table
that you have already created.)?
Q) Update Records 1( update battery life of all the mobiles to 10 hours in the Mobile_Specification
table)?
Q) Update Records 2 ( update the warranty in years to 2 and price as 20000 for all 'SamsungS2' mobiles
in mobile_master table)?
Q) Delete Records ( remove sales information details of the customer whose id is 'MB10010')?
A) INSERT INTO
CUSTOMER_INFO(CUSTOMER_ID,CUSTOMER_NAME,ADDRESS,MOBILE,EMAIL)VALUES('C01','Peter','Alabama',9884564566,'
[email protected]');
insert into
CUSTOMER_INFO(CUSTOMER_ID,CUSTOMER_NAME,ADDRESS,MOBILE,EMAIL)values('C02','Johan','Colorado',7324565689,'j
[email protected]');
Q) Display Customer Details(display the customer details such as customer id, name and phone
number.)?
(
Q) Display Distributor details display the distributor id, name and email of all the distributors. Sort the
records based on the distributor name in ascending order )
A) select distributor_id,distributor_name,Email from distributor order by distributor_name asc;
Q) Select all - Mobile details( display all the details of the mobile. Sort the results based on ime no in
ascending order)?
Q) Select Unique Operating System( display the OS of the mobile. Display unique values and sort them
in asc)?
Q) Display Customers whose name starts with S and ends with a the results based on name in
ascending order?
A) select Salesid,Sales_date,IME_No from Sales_Info where price<15000 and discount>500 order by Sales_date
desc;
Q) Customers with gmail account(display the customer id, name, address and email id of those
customers who have gmail account. Sort the results based on name in ascending order)?
A) select Customer_ID, Customer_Name, Address, Email from Customer_Info where Email like '%gmail.com%'
A) select IME_No, Model_Name, Manufacturer, Date_of_Manufac from Mobile_Master Where Price >10000 and
Warranty_in_years<5 order by Model_Name asc, IME_No desc;
A) select IME_No, Model_Name, Manufacturer, Price from Mobile_Master where Manufacturer = 'Nokia' or
Manufacturer = 'Samsung' order by Manufacturer asc;
A) select IME_No, Model_Name, Manufacturer, Price from Mobile_Master where Price between 10000' and
'20000' order by IME_No asc;
A) select IME_No, Model_Name, Manufacturer, Price from Mobile_Master where Distributor_ID not in('SA111',
'MC111') order by IME_No asc;
A) select Distributor_ID, Distributor_Name, Address, Mobilenumber from Distributor where Email is null order by
Distributor_Name desc;
Q) Increase in warranty?
Q) Fetch Third highest cabin cost ( display the third highest cabin cost rate)?
where (rate<(select max(rate) from cabincost where rate<(select max(rate) from cabincost)));
Q) Customer details based on discount(TOTAL_MOBILES_PURCHASED)?
A) select salesid, sales_date, ime_no, price, coalesce (TO_CHAR(discount), 'Not Applicable') as DISCOUNT FROM
SALES_INFO where to char(sales_date, 'Mon')='Feb' order by IME_NO;
Q) Price Calculation?
A) SELECT (TO_CHAR(SALES_DATE, 'MONTH')) AS MONTH, PRICE, CASE WHEN discount < 250 THEN ‘Low
Discount' WHEN 250<discount AND discount<750 THEN 'Medium Discount’ ELSE 'High Discount’ END AS
DISCOUNT_INFO FROM SALES_INFO order by PRICE;
Q) Mobile count based on warranty
A) select (spec_no||' has '|| dimension ||' dimension') as MOBILE_INFO, camera_quality from
mobile_specification order by MOBILE INFO desc;