-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect_students_courses.sql
More file actions
31 lines (24 loc) · 1.86 KB
/
select_students_courses.sql
File metadata and controls
31 lines (24 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/****** Script for SelectTopNRows command from SSMS ******/
SELECT [id]
,[lastname]
,[firstname]
,[dateofbirth]
,[enrollmentdate]
FROM [school].[dbo].[Students]
-- Retrieve only students with the last name 'Williams'
select lastname, firstname, dateofbirth
from school.dbo.students
where lastname = 'Student'
-- Retrieve only students with the word 'Student' in their last name
select lastname, firstname, dateofbirth
from school.dbo.students
where lastname like '%williams%'
-- Retrieve only Full Names of Students and their enrollment dates
select firstname+' '+lastname [Student Full Name], enrollmentdate [Enrollment Date]
from school.dbo.students
-- Select Courses with the number of credits greater than 2
select * from school.dbo.courses
where NumberOfCredits = 3
-- Select Courses with the number of credits 3 and less
select * from school.dbo.courses
where NumberOfCredits <= 3