0% found this document useful (0 votes)
152 views

NEHA PRASANTH - Exercise-Aggregate Functions in SQL

1. The document contains 13 questions related to performing operations on tables like INVENTORY, EMPLOYEE, CUSTOMER, and SALE in a database. 2. The questions involve adding/altering columns, calculating values like GST and commission, filtering records, aggregating data, and formatting dates. 3. Sample SQL queries are provided to answer each question by performing operations like updates, selects, aggregates, string functions and date functions.

Uploaded by

Neha Prasanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views

NEHA PRASANTH - Exercise-Aggregate Functions in SQL

1. The document contains 13 questions related to performing operations on tables like INVENTORY, EMPLOYEE, CUSTOMER, and SALE in a database. 2. The questions involve adding/altering columns, calculating values like GST and commission, filtering records, aggregating data, and formatting dates. 3. Sample SQL queries are provided to answer each question by performing operations like updates, selects, aggregates, string functions and date functions.

Uploaded by

Neha Prasanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Database Management

Exercise 1
Sl no. Questions
I
Table : INVENTORY

Table: EMPLOYEE

Table: CUSTOMER
Table :SALE

1 Calculate GST as 12% of Price and display the result after rounding it
off to one decimal place.
Ans Select round(0.12*Price,1) as GST from INVENTORY
2 Add a new column FinalPrice to the table inventory, which will have the
value as sum of Price and 12% of the GST

Ans Alter table INVENTORY


Add column FinalPrice int;

Update table INVENTORY


Set FinalPrice=Price+0.12*Price,1;
3 Let us now add a new column Commission to the SALE table. The
column Commission should have a total length of 7 in which 2 decimal
places to be there.
Ans Alter table SALE
Add column Commission float(7,2);
4 calculate commission for sales agents as 12 per cent of the SalePrice,
insert the values to the newly added column Commission and then
display records of the table SALE where commission > 73000.
Ans Update table SALE
Set Commission=0.12*SalePrice;

Select * from SALE where Commission>73000;


5 Display InvoiceNo, SalePrice and Commission such that commission
value is rounded off to 0.
Ans Select InvoiceNo, SalePrice, round(Commission,0) from sale;
6 Display customer name in lower case and customer email in upper case
from table CUSTOMER.
Ans Select lower(CustName), upper(Email) from CUSTOMER;
7 Display emails after removing the domain name extension “.com” from
emails of the customers.
Ans Select trim(‘.com’ from Email) from CUSTOMER;
8 Display details of all the customers having yahoo emails only.
Ans Select * from CUSTOMER where Email like “%@yahoo%”;
9 Select the day, month number and year of joining of all employees.
Ans Select day(DOJ), month(DOJ), year(DOJ) from EMPLOYEE;
10 If the date of joining is not a Sunday, then display it in the following
format: "Wednesday, 26, November, 1979."
Ans Select dayname(DOJ), day(DOJ), month(DOJ), year(DOJ) from EMPLOYEE
Where dayname(DOJ)<>’Sunday’
11 Display the total number of records from table INVENTORY having a
model as VXI.
Ans Select count(*) from INVENTORY where Model=’VXI’;
12. Display the total number of different types of Models available from table
INVENTORY.
Ans Select count(distinct Model) from INVENTORY;
13 Display the average price of all the cars with Model LXI from table
INVENTORY.
Ans Select avg(Price) from INVENTORY where Model=’VXI’;

You might also like