You are here: Re: Add last two values « MsSQL Server « IT news, forums, messages
Re: Add last two values

Posted by mcolson on 07/26/07 19:43

On Jul 26, 2:21 pm, Jason Lepack <jlep...@gmail.com> wrote:
> select
> sum(box)
> from (
> select top 2
> box
> from
> your_table
> order by
> id desc)
>
> Cheers,
> Jason Lepack
>
> On Jul 26, 3:16 pm, mcolson <mcolson1...@gmail.com> wrote:
>
> > I am trying to create a stored procedure that will add the last two
> > entries from a column. If I had a column named box, I would want to
> > add the two values in box, for which my ID column is Max and Max-1.
>
> > Is there anyone who can help me with this?
>
> > Matt

so i should
SET box = select
sum(box)
from (
select top 2
box
from
batchdaa
order by
IDnum desc)
?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация