SQL Question Set

SQL Community

Download SQL Database for Microsoft SQL Server

Note : Practice below practice questions website editor.
JOINS QUESTIONS

1. Write a SQL query to get employeeID, Job title, firstName, MiddleName, LastName and title from Person_Person and HumanResources_Employee

NOTE: OUTPUT on SQL Editor Count: 100 Rows.
OUTPUT 

2. Write a SQL query to get employeeID, Job title, firstName, LastName and startDate from Person, HumanResources_Employee and HumanResources_EmployeeDepartmentHistory tables.

NOTE: OUTPUT on SQL Editor Count: 100 Rows.

OUTPUT 

3. Write a SQL query to get all productCategoryId, CategoryName with Product SubcategoryId, name from Production_ProductSubcategory and Production_ProductCategory.

NOTE: OUTPUT on SQL Editor Count: 37 Rows.
OUTPUT 

4. Write a SQL query to get all employeeID, Job title WITH firstName, LastName, startDate from Person_Person, HumanResources_Employee and HumanResources_EmployeeDepartmentHistory tables.

NOTE: OUTPUT on SQL Editor Count: 100 Rows.
OUTPUT 

5. Write a query to join salesOrderHeader, SalesOrderDetail, SpecialOfferproduct and SpecialOffer table to retrieve two columns from each table.

OUTPUT on SQL Editor Count: 170 Rows.
OUTPUT 

6. Write SQL query to get addressline1, addressline2, city from person.address table where city start with ’M_ N’ .

(Row count:16)
OUTPUT 
NOTE: Practice below questions on MSSQL SERVER, it will not execute on site editor.
Store procedure Questions
Output on SQL server

8. Write a SQL query to create a stored procedure that takes a city name as an input parameter and retrieves the data of Address ID, Address line 1, City, Postal Code, and Modified Date from the ‘Person.Address’ table where the city [ Bothell (26 rows), Monroe (16 rows), Ottawa (7 rows)] matches the input parameter.

Output of city Bothell (26 rows)
Output of city Monroe (16 rows)

9. Create one simple table and create Store Procedure to insert records into that table and insert 5 records through Store Procedure.

Output 

10. Create Trigger on Table for update and if any record updated into that table then insert into log_table column status=’TABLE IS UPDATES ’

Output