HI
this is one of my SP
USE [behtop]
GO
/****** Object: StoredProcedure [dbo].[ViewSreg] Script Date: 03/04/2013 12:54:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter procedure [dbo].[ViewSreg1]
as
begin
select Behcode from Behcode group by Behcode, date having date=max(date)
end
when I use this SP it worke correctly and show Max date but when I merg this sP withother It show min date this is second SP
USE [behtop]
GO
/****** Object: StoredProcedure [dbo].[ViewSreg] Script Date: 03/04/2013 13:11:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[ViewSreg]
@Id int
as
begin
select *,
(select TOP 1 Behcode from Behcode group by Behcode, date having date=max(date)) behcode
from S_register
where id=@Id
end
Why this happen?
what should I do?
Best Regards