forked from balta-io/2805
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
439025f
commit 47da6b1
Showing
6 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
SELECT * FROM [Course] | ||
SELECT * FROM [Student] | ||
SELECT * FROM [StudentCourse] | ||
|
||
INSERT INTO | ||
[Student] | ||
VALUES ( | ||
'79b82071-80a8-4e78-a79c-92c8cd1fd052', | ||
'André Baltieri', | ||
'[email protected]', | ||
'12345678901', | ||
'12345678', | ||
NULL, | ||
GETDATE() | ||
) | ||
|
||
INSERT INTO | ||
[StudentCourse] | ||
VALUES ( | ||
'5f5a33f8-4ff3-7e10-cc6e-3fa000000000', | ||
'79b82071-80a8-4e78-a79c-92c8cd1fd052', | ||
50, | ||
0, | ||
'2020-01-13 12:35:54', | ||
GETDATE() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
INSERT INTO | ||
[Student] | ||
VALUES ( | ||
'c55390d4-71dd-4f3c-b978-d1582f51a327', | ||
'André Baltieri', | ||
'[email protected]', | ||
'12345678901', | ||
'11999999999', | ||
NULL, | ||
GETDATE() | ||
) | ||
|
||
INSERT INTO | ||
[StudentCourse] | ||
VALUES ( | ||
'5d8cf396-e717-9a02-2443-021b00000000', | ||
'c55390d4-71dd-4f3c-b978-d1582f51a327', | ||
50, | ||
0, | ||
'2021-01-15 12:35:54', | ||
GETDATE() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CREATE OR ALTER PROCEDURE spDeleteStudent ( | ||
@StudentId UNIQUEIDENTIFIER | ||
) | ||
AS | ||
BEGIN TRANSACTION | ||
DELETE FROM | ||
[StudentCourse] | ||
WHERE | ||
[StudentId] = @StudentId | ||
|
||
DELETE FROM | ||
[Student] | ||
WHERE | ||
[Id] = @StudentId | ||
COMMIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE OR ALTER PROCEDURE spStudentProgress ( | ||
@StudentId UNIQUEIDENTIFIER | ||
) | ||
AS | ||
SELECT | ||
[Student].[Name] AS [Student], | ||
[Course].[Title] AS [Course], | ||
[StudentCourse].[Progress], | ||
[StudentCourse].[LastUpdateDate] | ||
FROM | ||
[StudentCourse] | ||
INNER JOIN [Student] ON [StudentCourse].[StudentId] = [Student].[Id] | ||
INNER JOIN [Course] ON [StudentCourse].[CourseId] = [Course].[Id] | ||
WHERE | ||
[StudentCourse].[StudentId] = @StudentId | ||
AND [StudentCourse].[Progress] < 100 | ||
AND [StudentCourse].[Progress] > 0 | ||
ORDER BY | ||
[StudentCourse].[LastUpdateDate] DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CREATE OR ALTER VIEW vwCareers AS | ||
SELECT | ||
[Career].[Id], | ||
[Career].[Title], | ||
[Career].[Url], | ||
COUNT([Id]) AS [Courses] | ||
FROM | ||
[Career] | ||
INNER JOIN [CareerItem] ON [CareerItem].[CareerId] = [Career].[Id] | ||
GROUP BY | ||
[Career].[Id], | ||
[Career].[Title], | ||
[Career].[Url] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CREATE OR ALTER VIEW vwCourses AS | ||
SELECT | ||
[Course].[Id], | ||
[Course].[Tag], | ||
[Course].[Title], | ||
[Course].[Url], | ||
[Course].[Summary], | ||
[Course].[CreateDate], | ||
[Category].[Title] AS [Category], | ||
[Author].[Name] AS [Author] | ||
FROM | ||
[Course] | ||
INNER JOIN [Category] ON [Course].[CategoryId] = [Category].[Id] | ||
INNER JOIN [Author] ON [Course].[AuthorId] = [Author].[Id] | ||
WHERE | ||
[Active] = 1 |