Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Open SQL , Selecting Values Problem

Former Member
0 Kudos

Hello,

I have a table like the following

Book ID Min Value

-


5705 10.00

5705 15.00

5705 22.00

5706 10.00

5706 50.00

If I have a value, such as 8.00, how can I use a single select to bring back just one record, in this case it would be the Minimum Value 10.00 only, ie it has to be less than or equal to the minimum value , and the lowest figure?

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

PARAMETER: p_bookid.

DATA: l_minvalue.

SELECT MIN( minvalue ) INTO l_minvalue FROM DBTAB WHERE bookid = p_bookid GROUP BY bookid.

ENDSELECT.

-Kiran

2 REPLIES 2

Former Member
0 Kudos

PARAMETER: p_bookid.

DATA: l_minvalue.

SELECT MIN( minvalue ) INTO l_minvalue FROM DBTAB WHERE bookid = p_bookid GROUP BY bookid.

ENDSELECT.

-Kiran

Former Member
0 Kudos

hi ,

u can use following select query to get the Desired OUTPUT.

TABLES : DBTAB.

DATA: l_book_id,l_minvalue.

SELECT book_id minvalue INTO l_book_id l_minvalue FROM DBTAB WHERE minvalue = select min( minvalue ) from DBTAB.

ENDSELECT

Regards

vikas.