DBMS Lab Report 06 - Ankit Pangeni
DBMS Lab Report 06 - Ankit Pangeni
CSIT
4 Semesterth
OBJECTIVE
TO STUDY AND IMPLEMENT WHERE, SELECT, WILDCARDS, LIMIT AND AGGREGATE FUNCTIONS.
REQUIRED THEORY
The WHERE clause is used to filter records. It is used to extract only those records that fulfill a specified
condition. It is used to extract only those records that fulfill a specified condition. The WHERE clause is
not only used in SELECT statements, it is also used in UPDATE, DELETE, etc.! Its syntax with WHERE
clause is:
A wildcard character is used to substitute one or more characters in a string. Wildcard characters are
used with the LIKE operator. The LIKE operator is used in a WHERE clause to search for a specified
pattern in a column. ex: LIKE 'a%' Finds any values that starts with "a"
An aggregate function in SQL performs a calculation on multiple values and returns a single value. SQL
provides many aggregate functions that include avg, count, sum, min, max, etc. An aggregate function
ignores NULL values when it performs the calculation, except for the count function.
The SQL SELECT LIMIT statement is used to retrieve records from one or more tables in a database and
limit the number of records returned based on a limit value.
QUESTIONS
Table: Same as Lab 05. Use database dbms3.
1. Display a list of Publishers where publisher name starts with the letter „r‟
2. Display a list of Publishers where publisher name ends with the letter „n‟
3. Display a list of Books where book name contain the letter „en‟
4. Display a list of Books where the author‟s name ends with „ce‟, order the result in descending order by
book name.
7. Select top 2 books from table where price is less than 130
8. Display the lowest price of Book (in the result table, give the column name as “LowestPrice”)
9. Display the highest price of the Book (in the result table, give the column name as
“HighestPrice”)
10. Get the total value of the "Price" column from the "Book" table. (in the result table, give the
11. Get the average value of the "Price" column from the "Book" table. (in the result table, give
12. Find the total number of records in the Book table. (in the result table, give the column
name as “TotalBooks”)
13. Find how many books cost more than 60 rupees. (in the result table, give the column name
as “BooksCostMoreThan60”)
14. Find the total number of records in the Book table group by each author. (in the result table,
15. Find the total Price of the books group by each author. (in the result table, give the column
name as “BookPriceByAuthor”)
Question 1:
Question 2:
Question 4:
Question 5:
Question 6:
Question 7:
Question 9:
Question 10:
Question 11:
Question 12:
Question 14:
Question 15: