﻿SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

DROP PROCEDURE IF EXISTS [dbo].[uspGetAllSchemaMulasztasNotification]
GO

CREATE PROCEDURE [dbo].[uspGetAllSchemaMulasztasNotification]
AS
BEGIN

	SELECT TOP(5000)
		 mul.ID MulasztasId
		,mul.C_ORATANULOIID TanuloId
		,f.C_NYOMTATASINEV TanuloNev
		,i.C_AZONOSITO IntezmenyAzonosito
	FROM T_TANULOMULASZTAS mul
		INNER JOIN T_FELHASZNALO f ON f.ID = mul.C_ORATANULOIID AND f.TOROLT='F'
		INNER JOIN T_INTEZMENY i ON i.ID = mul.C_INTEZMENYID AND i.TOROLT='F'
		INNER JOIN T_TANEV tanev ON tanev.ID = mul.C_TANEVID AND tanev.C_AKTIV = 'T' AND tanev.TOROLT = 'F'
	WHERE
		mul.C_ISERTESITESELKULDVE = 'F'
		AND mul.TOROLT = 'F'
		AND mul.C_TIPUS IN (1499, 1500)
		ORDER BY mul.CREATED

END
GO