SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_policies_get_situation_by_mvt_date]
(
	@policy_id int = 0,
	@policy_mvt_date date
) 
as 
	set nocount on 
	

	/*
		DGE 27/04/2017

		Renvoyer la dernière situation d'un contrat pour une date donnée
	
	*/

	select	top 1 s.*
	from	pol_policies_situations s
	where	pols_policy_id = @policy_id
	and		pols_mvt_date <= @policy_mvt_date
	order by pols_mvt_date desc
GO
