70 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Transact-SQL
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Transact-SQL
		
	
	
	
	
	
 | 
						|
SET ANSI_NULLS ON
 | 
						|
GO
 | 
						|
SET QUOTED_IDENTIFIER ON
 | 
						|
GO
 | 
						|
 | 
						|
 | 
						|
IF OBJECT_ID('[dbo].[sp_GetTanulokFelmentesekHatarozatok]') IS NOT NULL 
 | 
						|
BEGIN
 | 
						|
  DROP PROCEDURE dbo.[sp_GetTanulokFelmentesekHatarozatok]
 | 
						|
END  
 | 
						|
GO
 | 
						|
-- =============================================
 | 
						|
-- Author:		Dőrr Tamás
 | 
						|
-- Create date: 2015.12.18.
 | 
						|
-- Description:	sp_GetTanulokFelmentesekHatarozatok
 | 
						|
-- =============================================
 | 
						|
CREATE PROCEDURE dbo.[sp_GetTanulokFelmentesekHatarozatok]
 | 
						|
	@OsztalyId		int,
 | 
						|
	@TanevId		int
 | 
						|
AS
 | 
						|
BEGIN
 | 
						|
	SET NOCOUNT ON;
 | 
						|
	
 | 
						|
	/*Alap adatok*/
 | 
						|
		select top(1)
 | 
						|
			i.C_IGAZGATONEVE as INT_IGAZGATO_NEV
 | 
						|
			,i.C_NEV as INT_NEV
 | 
						|
			,i.C_OMKOD as INT_OMKOD
 | 
						|
			,i.C_IRANYITOSZAM as INT_IRSZAM
 | 
						|
			,i.C_VAROS as INT_VAROS
 | 
						|
			,dbo.fnGetDokumentumIntezmenyCime(@tanevId) as INT_CIM
 | 
						|
			,ocs.C_NEV as OSZTALYCSOPORT_NEV
 | 
						|
			,osztf.C_VEZETEKNEV + ' ' + osztf.C_UTONEV as OSZTFO_NEV
 | 
						|
		from T_TANULOCSOPORT_OSSZES tcs
 | 
						|
		left outer join T_FELHASZNALO_OSSZES ft on ft.ID = tcs.C_TANULOID and ft.TOROLT = 'F'
 | 
						|
		left outer join T_OSZTALYCSOPORT_OSSZES ocs on ocs.ID = tcs.C_OSZTALYCSOPORTID and ocs.TOROLT = 'F'
 | 
						|
		left outer join T_INTEZMENYADATOK_OSSZES i on i.C_INTEZMENYID = tcs.C_INTEZMENYID and i.C_TANEVID = tcs.C_TANEVID and i.TOROLT = 'F'
 | 
						|
		left outer join T_OSZTALY_OSSZES o on o.ID = ocs.ID and o.TOROLT = 'F'
 | 
						|
		left outer join T_FELHASZNALO_OSSZES osztf on osztf.ID = o.C_OSZTALYFONOKID and osztf.TOROLT = 'F'
 | 
						|
		where
 | 
						|
			tcs.C_OSZTALYCSOPORTID = @OsztalyId
 | 
						|
			and tcs.C_TANEVID = @TanevId 
 | 
						|
			and tcs.TOROLT = 'F'
 | 
						|
			and tcs.C_BELEPESDATUM < GETDATE()
 | 
						|
			and (tcs.C_KILEPESDATUM is null or tcs.C_KILEPESDATUM >= GETDATE())
 | 
						|
		
 | 
						|
	/*Mulasztások*/
 | 
						|
				select
 | 
						|
			tt.C_NEV as TANTARGY
 | 
						|
			,tm.C_MENTESSEGOKA as MENTESSEG_OKA
 | 
						|
			,'' as TIPUSA
 | 
						|
			,ft.ID as TANULO_ID
 | 
						|
			,ft.C_VEZETEKNEV + ' ' + ft.C_UTONEV as TANULO_NEV
 | 
						|
			,ft.C_NYOMTATASINEV + ' ' + cast(ft.ID as nvarchar) as GROUPPARAMETER
 | 
						|
		from T_TANULOCSOPORT_OSSZES tcs
 | 
						|
		left outer join T_FELHASZNALO_OSSZES ft on ft.ID = tcs.C_TANULOID and ft.TOROLT = 'F'
 | 
						|
		left outer join T_OSZTALYCSOPORT_OSSZES ocs on ocs.ID = tcs.C_OSZTALYCSOPORTID and ocs.TOROLT = 'F'
 | 
						|
		inner join T_TANULOMENTESSEG_OSSZES tm on tm.C_TANULOID = ft.ID and tm.TOROLT = 'F'
 | 
						|
		left outer join T_TANTARGY_OSSZES tt on tt.ID = tm.C_TANTARGYID and tt.TOROLT = 'F'
 | 
						|
		where
 | 
						|
			tcs.C_OSZTALYCSOPORTID = @OsztalyId and 
 | 
						|
			tcs.C_TANEVID = @TanevId and
 | 
						|
			tcs.TOROLT = 'F' and
 | 
						|
			tcs.C_BELEPESDATUM < GETDATE() and
 | 
						|
			(tcs.C_KILEPESDATUM is null or tcs.C_KILEPESDATUM >= GETDATE())
 | 
						|
		order by ft.C_NYOMTATASINEV
 | 
						|
 | 
						|
		select C_OSZTALYFONOKID PartnerID From T_OSZTALY_OSSZES WHERE T_OSZTALY_OSSZES.ID = @OsztalyId AND T_OSZTALY_OSSZES.TOROLT='F' and T_OSZTALY_OSSZES.C_ALTANEVID = @TanevId
 | 
						|
END |