output parameters from row with max id

output parameters from row with max id

am 31.07.2007 23:45:39 von mcolson

I am trying to select multiple values from the row with the max id,
and output them within my stored procedure. How would I combine the
following two rows so that I only need to use "from mytable where
IDnum = (select (max(IDnum)) from mytable))" once. I have at least 8
other outputs I will be setting and would like this to work more
efficiently than setting each individually... if possible.

set @outmtd = (select outmtd from mytable where IDnum = (select
(max(IDnum)) from mytable))
set @outytd = (select outytd from mytable where IDnum = (select
(max(IDnum)) from mytable))

Thanks for any help you can give

Matt

Re: output parameters from row with max id

am 01.08.2007 00:02:42 von Joe Celko

>> I am trying to select multiple values from the row with the max id, and output them within my stored procedure. <<

Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. If you know how, follow ISO-11179 data element naming
conventions. Sample data is also a good idea, along with clear
specifications. It is very hard to debug code when you do not let us
see it.

Re: output parameters from row with max id

am 01.08.2007 05:29:42 von shiju

On Aug 1, 2:45 am, mcolson wrote:
> I am trying to select multiple values from the row with the max id,
> and output them within my stored procedure. How would I combine the
> following two rows so that I only need to use "from mytable where
> IDnum = (select (max(IDnum)) from mytable))" once. I have at least 8
> other outputs I will be setting and would like this to work more
> efficiently than setting each individually... if possible.
>
> set @outmtd = (select outmtd from mytable where IDnum = (select
> (max(IDnum)) from mytable))
> set @outytd = (select outytd from mytable where IDnum = (select
> (max(IDnum)) from mytable))
>
> Thanks for any help you can give
>
> Matt
I think this is what looking

select @outytd=outytd,@outmtd=outmtd
from mytable where IDnum = (select
(max(IDnum)) from mytable)

Re: output parameters from row with max id

am 01.08.2007 15:04:42 von mcolson

On Jul 31, 10:29 pm, shiju wrote:
> On Aug 1, 2:45 am, mcolson wrote:> I am trying to select multiple values from the row with the max id,
> > and output them within my stored procedure. How would I combine the
> > following two rows so that I only need to use "from mytable where
> > IDnum = (select (max(IDnum)) from mytable))" once. I have at least 8
> > other outputs I will be setting and would like this to work more
> > efficiently than setting each individually... if possible.
>
> > set @outmtd = (select outmtd from mytable where IDnum = (select
> > (max(IDnum)) from mytable))
> > set @outytd = (select outytd from mytable where IDnum = (select
> > (max(IDnum)) from mytable))
>
> > Thanks for any help you can give
>
> > Matt
>
> I think this is what looking
>
> select @outytd=outytd,@outmtd=outmtd
> from mytable where IDnum = (select
> (max(IDnum)) from mytable)

that was exactly what I needed. Thanks