SQL Revision
SQL Revision
2) What is NULL ? How it is different from Zero ? How are NULL values treated by aggregate functions?
Table : Salesman
Write SQL queries using SQL functions to perform the following operations.
(i) Display salesman name and bonus after rounding off to zero decimal places.
(ii) Display the month name for the date of join of salesman.
(iii) Display the minimum salary of the Salesman.
4) What is the purpose of GROUP BY clause in MySQL? How is it different from ORDER BY clause?
5) Write SQL commands for the statements (i) to (iii) which are based on the given table PERSON
Page |2
6) Naveen, a database administrator has designed a database for a Computer Stock. Help her by
writing answers of the following questions based on the given table:
TABLE: Stock
10) Briefly explain the purpose of the following: i. power() ii. mod()
Page |3
11) Based on the SQL table EXAM, write suitable queries for the following:
Predict the output of the following queries based on the table EXAM given above:
i. SELECT COUNT * FROM EXAM;
ii. SELECT SName, Percentage FROM EXAM WHERE Name LIKE “N%”;
iii. SELECT ROUND (Percentage, 0) FROM EXAM WHERE Adno = “1004”;
13) Vijay manages a database with the latest price of Electronic Devices. He created a table named
DEVICES. Assist him by writing the following Queries:
16)
Consider “Winners never quit”. Write the queries for the following tasks.
i. Write a command to display “quit”.
ii. Write a command to check the first occurrence of letter ‘n’
17) Basedontable Employee given here, write suitable SQL queries for the following:
Predict the output of the following queries based on the above table Employee:
i. SELECT LEFT (Name , 2) FROM Employee WHERE Gender = “F”;
ii. SELECT AVG(Salary) FROM Employee WHERE Dept = “Sales”;
iii. SELECT SUM(Salary) FROM Employee WHERE Designation = “Clerk”;
Page |5
Help her in writing SQL queries to the perform the following task:
a) Insert a new record in the table having following values:
[6,'Abhinav','office',12.10.2023]
Page |6
23) What is the difference between Aggregate Function and Scaler Function in MySQL? Provide the name
of one function from each.
24) Consider the SQL table "PRODUCT_SALES" with the following data:
26) Niranjan is responsible for managing a database in a financial company. The company stores financial
transaction data in a table named FINE_TRNC. Niranjan needs your assistance in writing SQL queries to
retrieve specific information from the table. The attributes of the table are: TransactionDate,
TransactionAmount.
1. Write a query to display the date of the most recent transaction.
2. Write a query to retrieve the average transaction amount for the month of June.
3. Write a query to list the maximum amount for the transaction that occurred in the month of December.
4. Write a query to count the total number of transactions that took place in the year 2023.
27) Write suitable SQL queries for the following:
1. Write an SQL query to calculate 3 raised to the power of 4.
2. To round off the value 1969.5538 without any decimal part
3. Display the current date.
4. Convert the string 'After the test, take some rest’ to uppercase:
5. Return the length of the string 'To chaloshurukartehain'.
28) Take a look at the table structure of the table ‘IndianAlbums’ and `Artist_Info`
- AlbumName: "Lagaan"
- ReleaseYear: 2001
- Genre: "Soundtrack"
- Sales: 5000000
- Language: "Hindi"
2. Update the `IndianAlbums` table to modify the sales of the album with `AlbumID` 3 to 1000000.
3. Delete the record of the album named "Dil Se" from the `IndianAlbums` table.
4. Alter the table structure of `IndianAlbums` to add a new column named "Language" of data type
VARCHAR(50).
5. Select all albums released in the year 1990 or later, and for each album, retrieve the album name,
release year, genre, and the name of the artist.
=========