Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

RDBMS_Syllabus_Assignment_LabPractice

The document outlines various SQL queries and concepts related to RDBMS, including creating databases and tables, performing CRUD operations, and using SQL functions like joins and subqueries. It provides specific examples of queries to select unique records, delete duplicates, and analyze employee salaries, among others. Additionally, it includes sample tables and expected outputs for various SQL queries.

Uploaded by

Gaurav gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

RDBMS_Syllabus_Assignment_LabPractice

The document outlines various SQL queries and concepts related to RDBMS, including creating databases and tables, performing CRUD operations, and using SQL functions like joins and subqueries. It provides specific examples of queries to select unique records, delete duplicates, and analyze employee salaries, among others. Additionally, it includes sample tables and expected outputs for various SQL queries.

Uploaded by

Gaurav gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

www.codebetter.

in
+91 88230 75444

401, Shekhar Central, Palasia Square, Indore, MP - 452001 +91 9993928766

RDBMS

Section 1 -

- Create Database and Tables


- Create and Alter Table with all constraint
- Select, Insert, Update, and Delete
- OrderBy, GroupBy
- Primary and Foreign Key
- Joins and SubQuery

*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

What will be the result of the query below?


Select * from eunners where id not in (select winner_id from races)
*13. Assume a schema of EMP (ID, Name, DeptId), Dept (Id, Name).
If there are 10 records in the Emp table and 5 records in the Dept table, how many rows will be displayed in
the result of the following SQL query:
Query: Select * from Emp,Dept
*14. Suppose you have a table “Loan_Records”.
Table: Loan_Records

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?

#1. What will be the output of the below query?


Query: Select Company, Avg(salary) from AV1 having avg(salary) > 1200 group by Company
where Salary > 1000;
#2. SQL Query to find the second highest salary of Employee
#3. SQL Query to find Max Salary from each department.
#4. Write SQL Query to display the current date?
#5. Write an SQL Query to print the name of the distinct employee whose DOB is between 01/01/1960 to
31/12/1975.
#6. Write an SQL Query to find an employee whose salary is equal to or greater than 10000.
#7. Write SQL Query to find duplicate rows in a database? And then write SQL Query to delete them?
#8. How do you find all employees who are also managers?
#9. Write a SQL Query to find all duplicates emails in a table named Person.

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

You might also like