-- =============================================
-- Author:		<Dirk Strauss>
-- Create date: 	<14 July 2017>
-- Description:	<Get the room type counts>
-- =============================================
CREATE PROCEDURE [dbo].[sproc_PROP1_SumRoomCounts] 
	-- Add the parameters for the stored procedure here
	@propertyID INT
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

     
     SELECT
     Bedrooms = (SELECT SUM (Bedrooms_Bedrooms_Count) FROM dbo.publ_Bedrooms WHERE ParentSurfaceItemId = @propertyID AND isActive = 1),
     Bathrooms = (SELECT SUM (Bathrooms_Bathrooms_Count) FROM dbo.publ_Bathrooms WHERE ParentSurfaceItemId = @propertyID AND isActive = 1),
     ReceptionRooms = (SELECT SUM (ReceptionRooms_ReceptionRooms_Count) FROM dbo.publ_ReceptionRooms WHERE ParentSurfaceItemId = @propertyID AND isActive = 1),
     Garages = (SELECT SUM (Garages_Garages_Count) FROM dbo.publ_Garages WHERE ParentSurfaceItemId = @propertyID AND isActive = 1)
END




