469,923 Members | 1,550 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

output parameters from row with max id

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

Jul 31 '07 #1
3 2051
>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.

Jul 31 '07 #2
On Aug 1, 2:45 am, mcolson <mcolson1...@gmail.comwrote:
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)

Aug 1 '07 #3
On Jul 31, 10:29 pm, shiju <shiju.sam...@gmail.comwrote:
On Aug 1, 2:45 am, mcolson <mcolson1...@gmail.comwrote: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

Aug 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bari Allen | last post: by
5 posts views Thread by vivienne.netherwood | last post: by
4 posts views Thread by Janaka | last post: by
2 posts views Thread by Bari Allen | last post: by
3 posts views Thread by juststarter | last post: by
1 post views Thread by Joe Van Meer | last post: by
1 post views Thread by Garth Wells | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.