DROP PROCEDURE IF EXISTS uspGetTanevRendjeData
GO

CREATE PROCEDURE uspGetTanevRendjeData
  @pTanevId int

AS 
BEGIN
  SET NOCOUNT ON;

  SELECT
     tr.ID AS Id
    ,tr.C_DATUM AS Datum
    ,tr.C_HETNAPJA AS NapId
    ,tr.C_NAPTIPUSA AS NapTipusId
    ,tr.C_HETIREND AS HetirendId
    ,tr.C_MEGJEGYZES AS Megjegyzes
    ,(SELECT count(1) FROM T_OSZTALYCSOPORT_TANEVRENDJE WHERE T_OSZTALYCSOPORT_TANEVRENDJE.C_TANEVRENDJEID = tr.ID) VonatkozoOsztalyCsoportSzam
    ,tr.C_OSSZESCSOPORTRAVONATKOZIK AS IsOsszesCsoportraVonatkozik
    ,tr.C_ISURESORAREND AS IsUresOrarend    
    ,tr.C_ORARENDINAP AS IsOrarendiNap
    ,tv.C_NEV AS TanevNev
  FROM T_TANEVRENDJE_OSSZES tr
    INNER JOIN T_TANEV_OSSZES tv ON tv.ID = tr.C_TANEVID AND tv.TOROLT = 'F'
  WHERE tr.C_TANEVID = @ptanevId
    AND tr.TOROLT = 'F'
END

GO

