CREATE FUNCTION [C6MartPeriodico].[getCreditRiskClassEmit] 
(
	@ully as decimal(10,3),
	@NumTitRc as smallint 
)
RETURNS smallint
AS
BEGIN
	-- Declare the return variable here
	DECLARE @creditClassRisk as smallint
	SET @ully = @ully/100
	-- Add the T-SQL statements to compute the return value here
	IF @NumTitRc > 0
	begin
	SELECT @creditClassRisk = 
		ordine
		from C6MartPeriodico.RischioEmittenti
		where min <= @ully and @ully <= max
	end
	else
	set @creditClassRisk = null
	RETURN @creditClassRisk
END