You are on page 1of 2

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON
go

-- Returns a user and the number of courses he has attended


ALTER proc [dbo].[usp_UserInfo]
as
begin
select FirstName as 'User' ,Count(*)as 'Total Courses'
from Users,UserCourses
where UserCourses.UserID = Users.UserID
Group By FirstName
End

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER Procedure [dbo].[uspGetTrainDetails]

as
begin
select CourseName as 'Training Course ', FirstName as 'User'
,Completed as 'completion Status'

from UserCourses
inner join Courses

on UserCourses.CourseID = Courses.CourseID

inner join Users

on UserCourses.UserID = Users.UserID

end

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- Returns all courses and Total number of users for it

ALTER Proc [dbo].[uspTotalUserCourses]


as
begin
select CourseName as 'Name of Courses' ,Count(*)as 'Total Users'
from Courses,UserCourses
where UserCourses.CourseID = Courses.CourseID
Group By CourseName

end

You might also like