Re: How to find the last known value in the following dataset

From: avnrao (avn_at_newsgroups.com)
Date: 11/29/04


Date: Mon, 29 Nov 2004 19:12:42 +0530

Select Material, Max(Month) from Table1
Where StockMovement is not null and Material = @Material and Month <= @Month
group by Material

Av.
http://dotnetjunkies.com/WebLog/avnrao
http://www28.brinkster.com/avdotnet

"Karen Middleton" <karenmiddleol@yahoo.com> wrote in message
news:a5fd468a.0411290413.3c42509b@posting.google.com...
> Hello All
>
> I have the following scenario:
>
>
> Material Month StockMovement
> ======== ===== =============
> ABC001 001 120
> ABC001 002
> ABC001 003
> ABC001 004 158
> ABC001 005
> ABC001 006
>
> XYZ001 001
> XYZ001 002 28
> XYZ001 003
> XYZ001 004
> XYZ001 005 32
> XYZ001 006 18
>
>
> In this case in the month of Oct 2005 when I take my stock movement
> since the last known movement for material ABC001 in 158 that should
> be my movement for ABC001 in Period 010. Similarly, for material
> XYZ001 the last known movement in period 006 is 18 that must be the
> stock movement for material XYZ001 the stock movement in Period 004 is
> 28 which is the last known movement in period 002.
>
>
> Can you kindly share the code and ideas for programming this scenario
> in both Access and SQL Server. Is there a built-in function that can
> assist here.
>
> Thanks
> Karen



Relevant Pages

  • Re: How to find the last known value in the following dataset
    ... Select Material, Maxfrom Table1 ... > Material Month StockMovement ... > Can you kindly share the code and ideas for programming this scenario ... Is there a built-in function that can ...
    (microsoft.public.sqlserver.programming)
  • How to find the last known value in the following dataset
    ... Material Month StockMovement ... In this case in the month of Oct 2005 when I take my stock movement ... Can you kindly share the code and ideas for programming this scenario ... Is there a built-in function that can ...
    (microsoft.public.sqlserver.programming)
  • How to find the last known value in the following dataset
    ... Material Month StockMovement ... In this case in the month of Oct 2005 when I take my stock movement ... Can you kindly share the code and ideas for programming this scenario ... Is there a built-in function that can ...
    (microsoft.public.access.queries)