﻿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
    ,tantargy.C_NEV TantargyNev
    ,tanora.C_DATUM MulasztasDatuma
    ,tanora.C_ORASZAM OraSorszama
    ,mul.C_ORATANULOIID TanuloId
    ,f.C_IDPEGYEDIAZONOSITO IdpUniqueId
    ,f.C_NYOMTATASINEV TanuloNev
    ,i.C_AZONOSITO IntezmenyAzonosito
    ,tanev.ID TanevId
  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'
    INNER JOIN T_TANITASIORA tanora ON tanora.ID = mul.C_TANITASIORAKID AND tanora.TOROLT = 'F'
    INNER JOIN T_TANTARGY tantargy ON tantargy.ID = tanora.C_TANTARGYID AND tantargy.TOROLT = 'F'
  WHERE
    mul.C_ISERTESITESELKULDVE = 'F'
    AND mul.TOROLT = 'F'
    AND mul.C_TIPUS IN (1499, 1500)
    ORDER BY mul.CREATED
END
GO

