RDBMS_Syllabus_Assignment_LabPractice
RDBMS_Syllabus_Assignment_LabPractice
in
+91 88230 75444
RDBMS
Section 1 -
*1. How to select UNIQUE records from a table using a SQL Query?
*2. How to delete DUPLICATE records from a table using a SQL Query?
*3. How to read TOP 5 records from a table using a SQL Query?
*4. How to read Last 5 records from a table using a SQL Query?
*5. How to find the employee with second MAX Salary using a SQL Query?
*6. How to find the employee with third MAX Salary using a SQL Query?
*7. Assume you have the below tables on sessions that users have, and a user’s table. Write a query to get the
active user count of daily cohorts.
*8. Assume you are given the below table on transaction from users for purchase. Write a query to get the list of
customers where their earliest purchase was at least $50
*9. Assume you are given the below table on transactions from users. Write a query to get the number of users and
total products bought per latest transaction date where each user is bucketed into their latest transaction date.
*10. Assume you are given the below tables on users and their time spent on sending and opening Snaps. Write a
query to get the breakdown for each age breakdown of the percentage of time spent on sending versus opening
snaps.
*11. Assume you are given the below table on reviews from users. Define a top-rated place as a business whose
reviews only consist of 4 or 5 starts. Write a query to get the number and percentage of businesses that are top-
rated places.
*12. Given the following tables:
Sql> Select * from runners;
Table: runners
Id Name
1 John Doe
2 John Doe
3. Alice Jones
4 Bobby Louis
5 Lisa Romero
Sql> select * from races;
Table: races
id Event Winner_id
1 100 meter dash 2
2 500 meter dash 3
3 Cross-country 2
4 Triathalon NULL
Query: select Count(*) from ((select Borrower, Bank_Manager from Loan_Records) As Natural
Join (Select Bank_Manager, Loan_Amount from Loan_Records) as T);
What is the output of the following SQL query?
For example, your query should return the following for the above table.
#10. Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its
previous (yesterday’s) dates.
#11. The Employee table holds all employee including their managers. Every employee has ab Id, and there is also
a column for the managerId.
Given the Employee table, write a SQL query that finds out employees who earn more than their managers. For
the above table, Joe is the only employee who earn more than his manager.
#12. X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster
indicating the ‘movies’ ratings and descriptions. Please write a SQL Query to output movies with an odd
numbered ID and a description that is not ‘boring’. Order the result by rating.
Table: Cinema
#13. Write a SQL query to get the nth highest salary from the Employee table.
Id Salary
1 100
2 200
3 300
For example, given the above Employee table, the nth highest salary where n=2 is 200. If there is no nth highest
salary, then the query should return null.
#14. From the following table of user IDs, actions, and dates, write a query to return the publication and cancellation
rate for each user.
#15. From the following table of transactions between two users, write a query to return the change in net worth for
each user, ordered by decreasing net change.
#16. From the following table containing a list of dates and items ordered, write a query to return the most frequent
item ordered on each date. Return multiple items in the case of a tie.
Table: items
date Item
1-1-20 Apple
1-1-20 Apple
1-1-20 Pear
1-1-20 Pear
1-2-20 Pear
1-2-20 Pear
1-2-20 pear
1-2-20 orange