SSRS_FAC

The shared datasets used in reports
Post Reply
User avatar
robinwilson16
Site Admin
Posts: 184
Joined: Sun Oct 16, 2016 6:46 pm
Forename: Robin
Surname: Wilson
College Name: FEA
Position: MIS Consultant
LinkedIn Profile: https://www.linkedin.com/in/robinwilson16

SSRS_FAC

Post by robinwilson16 » Mon Feb 20, 2017 5:58 pm

Lists faculties:

Code: Select all

CREATE FUNCTION [dbo].[SSRS_FAC] (
	@Session VARCHAR(7)
)
RETURNS TABLE
AS
RETURN

--DECLARE @Session VARCHAR(7) = '2016-17'
SELECT
	Code = FAC.d_reference,
	Description = FAC.d_reference + ' - ' + FAC.d_name
FROM ulive.dbo.capd_department FAC
INNER JOIN (
	SELECT DISTINCT
		FacID = PRG.m_moduledept
	FROM ulive.dbo.capd_module PRG
	WHERE
		PRG.m_start <= LEFT ( @Session, 2 ) + RIGHT ( @Session, 2 ) + '-07-31'
		AND PRG.m_end >= LEFT ( @Session, 4 ) + '-08-01'​​
		AND PRG.m_type = 'P'
		AND PRG.m_status IN ( 'R', 'P' )
) CRS On CRS.FacID = FAC.d_id
WHERE
	COALESCE ( FAC.d_start, LEFT ( @Session, 2 ) + RIGHT ( @Session, 2 ) + '-07-31' ) <= LEFT ( @Session, 2 ) + RIGHT ( @Session, 2 ) + '-07-31'
	AND COALESCE ( FAC.d_end, LEFT ( @Session, 4 ) + '-08-01'​​ ) >= LEFT ( @Session, 4 ) + '-08-01'​​
UNION ALL
SELECT
	Code = NULL,
	Description = '-- All Faculties --'
Attachments
SSRS_FAC.rsd
(1.05 KiB) Downloaded 9 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest