﻿DROP PROCEDURE IF EXISTS [dbo].[uspGetAllSchemaKikuldendoFeljegyzes]
GO

CREATE PROCEDURE [dbo].[uspGetAllSchemaKikuldendoFeljegyzes]
AS
BEGIN
SET NOCOUNT ON;

  SELECT TOP(5000)
     tes.ID FeljegyzesId
    ,fh.ID TanuloId
    ,fh.C_NYOMTATASINEV TanuloNev
    ,i.C_AZONOSITO IntezmenyAzonosito
  FROM T_TANULOESEMENY tes
	INNER JOIN T_TANULO_TANULOESEMENY ttes ON tes.ID = ttes.C_TANULOESEMENYID
    INNER JOIN T_FELHASZNALO fh ON fh.ID = ttes.C_TANULOID AND fh.TOROLT = 'F'
    INNER JOIN T_INTEZMENY i ON i.ID = tes.C_INTEZMENYID AND i.TOROLT='F'
	INNER JOIN T_TANEV tanev ON tanev.ID = tes.C_TANEVID AND tanev.C_AKTIV = 'T' AND tanev.TOROLT = 'F'
  WHERE
    tes.C_TIPUS != 5483
    AND tes.C_ISERTESITESELKULDVE = 'F'
    AND tes.TOROLT = 'F'
	ORDER BY tes.CREATED

END
GO			