0% found this document useful (0 votes)
155 views5 pages

Practical Assignment #6 (Based On Single Row and Aggregate Functions in Mysql)

This document provides instructions and questions for a practical assignment involving SQL queries on multiple tables. It includes 5 questions related to creating and querying tables to return aggregated data and perform calculations. The tables include data about charities, grocery items, students and sports, items and bills, departments and employees, and vehicle registration and traffic offenses. Students are asked to write SQL queries to return things like minimum and maximum values, counts by groups, sums, and averages. Key constraints are also to be identified for each table.

Uploaded by

jagriti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
155 views5 pages

Practical Assignment #6 (Based On Single Row and Aggregate Functions in Mysql)

This document provides instructions and questions for a practical assignment involving SQL queries on multiple tables. It includes 5 questions related to creating and querying tables to return aggregated data and perform calculations. The tables include data about charities, grocery items, students and sports, items and bills, departments and employees, and vehicle registration and traffic offenses. Students are asked to write SQL queries to return things like minimum and maximum values, counts by groups, sums, and averages. Key constraints are also to be identified for each table.

Uploaded by

jagriti
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 5

Class XII: Informatics Practices

Practical Assignment #6 (Based on Single Row and Aggregate Functions in MySQL )

Ques 1: Create the following table named "Charity" and write SQL queries for the tasks that follow:

1. Display all first names in lowercase


2. Display all last names of people of Mumbai city in uppercase
3. Display Person Id along with First 3 characters of his/her name.
4. Display first name concatenated with last name for all the employees.
5. Display length of address along with Person Id
6. Display last 2 characters of City and Person ID.
7. Display Last Names and First names of people who have "at" in the second or third position in their first
names.
8. Display the position of 'a' in Last name in every row.
9. Display Last Name and First name of people who have "a" as the last character in their First names.
10. Display the first name and last name concatenated after removing the leading and trailing blanks.
11. Display Person Id, last names and contribution rounded to the nearest rupee of all the persons.
12. Display Person Id, last name and contribution with decimal digits truncated of all the persons.
13. Display Last name, contribution and a third column which has contribution divided by 10. Round it to two
decimal points

Ques 2: Create the following table named "Grocer" and write SQL queries for the tasks that follow:

1. Display Item name, unit price along with Date of purchase for all the Items.
2. Display Item name along with Month (in number) when it was purchased for all the items.
3. Display Item name along with year in which it was purchased for all the items.
4. Display Item Id, Date of Purchase and day name of week (e.g. Monday) on which it was purchased for all the
items.
5. Display names of all the items that were purchased on Mondays or Tuesdays.
6. Display the day name of the week on which Rice was purchased.
7. Display the Item name and unit price truncated to integer value (no decimal digits) of all the items.
8. Display current date

Page 1 of 5
Class XII: Informatics Practices
Practical Assignment #6 (Based on Single Row and Aggregate Functions in MySQL )

Ques 3 : Answer the questions that follow based on the tables Students and Sports

 Identify the following keys in the above tables.


 Candidate Keys,
 Primary Key / Composite Primary key
 Alternate Keys
 Foreign keys

 In a database create the above tables with suitable constraints and insert records in them:

 Based on these tables write SQL statements for the following queries:
a) Display the lowest and the highest classes from the table STUDENTS.
b) Display the number of students in class 10.
c) Display the number of students in each class from the table STUDENTS.
d) Display the Number of students with each coach.
e) Display the number of students in each Game, but do not display this data for the games with
less than 2 students.
f) Display the number students in each section of each class.

Page 2 of 5
Class XII: Informatics Practices
Practical Assignment #6 (Based on Single Row and Aggregate Functions in MySQL )

Ques 4 : Answer the questions that follow based on the tables Items and Bills

 Identify the following keys in the above tables.


 Candidate Keys,
 Primary Key / Composite Primary key
 Alternate Keys
 Foreign keys

 In a database create the above tables with suitable constraints and insert records in them:

 Based on these tables write SQL statements for the following queries:
a) Display the average rate of a South Indian item.
b) Display the number of items in each category.
c) Display the total quantity sold for each item.
d) Display total quantity of each item sold but don't display this data for the items whose total
quantity sold is less than 3.
e) Display the total items sold on each date.

Page 3 of 5
Class XII: Informatics Practices
Practical Assignment #6 (Based on Single Row and Aggregate Functions in MySQL )

Ques 5 : Answer the questions that follow based on the tables Department and Employee

 Identify the following keys in the above tables.


 Candidate Keys,
 Primary Key / Composite Primary key
 Alternate Keys
 Foreign keys

 In a database create the above tables with suitable constraints and insert records in them:

 Based on these tables write SQL statements for the following queries:
a) Display the minimum and the maximum salary from the Employee table.
b) Display the sum of salary in each Zone.
c) Display the number of employees in each department, but do not display this data for the
departments with less than 2 employees.
d) Display the sum of salary in the departments where average salary is more than 30000.

Page 4 of 5
Class XII: Informatics Practices
Practical Assignment #6 (Based on Single Row and Aggregate Functions in MySQL )

Ques 5 : Answer the questions that follow based on the tables Department and Employee
VEHICLE
REGNO REGDATE OWNER ADDRESS
DL6CQ1236 2008-06-18 Utkarsh Madan C-32, Punjabi Bagh
DL3CQ7135 2009-05-10 Naresh Sharma 31, Mohan Nagar
DL3CQ7190 2009-04-25 Subya Akhtar 12, Janak Puri
RZ9CP1578 2010-01-14 David DSouza D-34, Model Town
DL6CQ2259 2008-07-11 Mohini Mehta 37, Rohini
RZ9CP1869 2010-02-06 Peter Jones 21/32, Vishal Enclave
OFFENCE
OFFENCE_CODE OFF_DESC CHALLAN_AMT
101 Red Light Jumping 100
107 Driving without Helmet 100
108 Not Displaying Number Plate 100
120 Driving without Licence 500
121 Driving by Minors 500
122 Over Speeding 400
143 Using Mobile Phone while Driving 1000
144 Wrong Overtaking 100
CHALLAN
CHALLAN_NO CH_DATE REGNO OFFENCE
1004030010 2010-04-03 RZ9CP1869 107
1004030015 2010-04-03 DL6CQ1236 120
1004031220 2010-04-03 DL3CQ7135 143
1004040020 2010-04-04 RZ9CP1578 107
1004050150 2010-04-05 DL3CQ7135 101
1004050610 2010-04-05 DL6CQ1236 143
1004050755 2010-04-05 DL6CQ2259 101

 Identify the following keys in the above tables.


 Candidate Keys,
 Primary Key / Composite Primary key
 Alternate Keys
 Foreign key

 In a database create the above tables with suitable constraints and insert records in them:

 Based on these tables write SQL statements for the following queries:
a) Display the dates of first registration and last registration from the table Vehicle
b) Display the number of challans issued on each date from Challan table.
c) Display the total number of challans issued for each offence from the Challan table.
d) Display the total number of vehicles for which the 3rd and 4th characters of RegNo are '6C'in the
Vehicle table.
e) Display the RegNo of all vehicles which have been challaned more than once.

Page 5 of 5

You might also like