Get All Instructors Names Without Repetition
Get All Instructors Names Without Repetition
Get All Instructors Names Without Repetition
Certainly! Here's the provided SQL code written in Beautiful Obsidian Markdown:
# Lab_5_1
## Use ITI
SELECT
S.St_Id AS [Student ID],
ISNULL(S.St_Fname + ' ' +S.St_Lname,'No Name') AS [Student Full Name],
ISNULL(D.Dept_name,'No Department') AS [Department Name]
FROM Student AS S
JOIN Department AS D
ON S.Dept_id = D.Dept_id
5. Display student full name and the name of the course he is taking
SELECT
ISNULL(S.St_Fname + ' ' +S.St_Lname,'No Name') AS [Student Full Name],
C.Crs_Name AS [Course Name]
FROM Student AS S
JOIN Stud_Course AS SC
ON S.St_Id = SC.St_Id
JOIN Course AS C
ON SC.Crs_ID = C.Crs_Id
WHERE SC.Grade IS NOT NULL
8. Display instructors who have salaries less than the average salary
of all instructors.
SELECT Ins_Name
FROM Instructor
WHERE Salary < (SELECT AVG(salary) FROM Instructor)
-- OR
SELECT TOP (2) Salary, ROW_NUMBER() OVER (ORDER BY Salary DESC) AS RowNum
FROM Instructor
11. Select instructor name and his salary but if there is no salary
display instructor bonus keyword. “use coalesce Function”
SELECT AVG(salary)
FROM Instructor
13. Select Student first name and the data of his supervision
SELECT TOP(1) *
FROM Student
ORDER BY NEWID()
Lab_5_2
Use AdventureWorks2012
1. Display the SalesOrderID, ShipDate of the SalesOrderHeader table
(Sales schema) to show SalesOrders that occurred within the period
‘7/28/2002’ and ‘7/29/2014’
SELECT *
FROM Production.Product
WHERE Name LIKE ('B%')
-- UPDATE Production.ProductDescription
-- SET Description = 'Chromoly steel_High of defects'
-- WHERE ProductDescriptionID = 3
UPDATE Production.ProductDescription
SET Description = 'Chromoly steel_High of defects'
WHERE ProductDescriptionID = 3
SELECT Description
FROM Production.ProductDescription
WHERE Description LIKE '%[_]%'
SELECT SUM(TotalDue)
FROM Sales.SalesOrderHeader
WHERE OrderDate BETWEEN '7/1/2001' AND '7/31/2014'
13. Try the previous query but without transferring the data?