﻿/****** Script for SelectTopNRows command from SSMS  ******/
-- =============================================
-- Description:  sp_GetTanuloCsoport by tanuloId, osztalyID es Datum
-- =============================================
DROP PROCEDURE IF EXISTS [dbo].[sp_GetTanuloOsztalyCsoport]
GO

CREATE PROCEDURE [dbo].[sp_GetTanuloOsztalyCsoport]
  @tanuloId    INT,
  @osztalyId    INT,
  @datum    DATETIME
AS
BEGIN
  SET NOCOUNT ON;
  SELECT *
  FROM T_TANULOCSOPORT_OSSZES  
  WHERE C_TANULOID = @tanuloId AND (@osztalyId IS NULL OR C_OSZTALYCSOPORTID = @osztalyId) AND TOROLT = 'F'
  AND (C_BELEPESDATUM < ISNULL(@datum,GetDate()) AND (C_KILEPESDATUM IS NULL OR C_KILEPESDATUM > ISNULL(@datum,GetDate())))

END
GO
