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: 

How to fetch the values with from and to

Former Member
0 Kudos

Hi All,

in table(ZBOX) records are like this

field1 field2 field3 field4

523012 FGD100 FGD500 BOTTLE

523012 FGD501 FGD800 BOX

Now in selection parameters i am giving FGD200, Based on this value how to get the record(1st record) from Ztable(ZBOX).

please tell me how to write the select query regarding this.

Thanks in advance.

9 REPLIES 9

Former Member
0 Kudos

Hi,

Either you can use select single or select UPTO 1 rows statement to fetch the first record based on ur selection.

Select single field1 field2 field3 field4 from ZBOX

where field1 = selection parameter.

Former Member
0 Kudos

HI.

do u want to select the first record from the ztable ( zbox ).

Is that the condition.

0 Kudos

Hi,

I don't want only first record, i have given one example.

523012 FGD100 FGD500 BOTTLE

523013 FGD501 FGD800 BOX

523014 FGD801 FGD900 BOX

suppsoe if iam giving FGD520 System has to fetch 2nd record , like the same way if i am giving FGD822 System has to fetch 3rd record ...

Edited by: satya palli on Jun 8, 2009 7:01 AM

0 Kudos

Hello


select single * from ZBOX where field2 <= p_parameter and field3 > p_parameter.

Former Member
0 Kudos

Hai,

Write the SELECT Query as follows:

SELECT * FROM ZBOX WHERE fieldname = FGD200.

Former Member
0 Kudos

Hi,

DATA V_VALUE(4) , NEW_VAL(5).

Move the value of the first 4 characters of the parameter FIELD3 to V_VALUE.

eg. if FGD520 we will move FGD5 to V_VALUE.

then concatenate V_VALUE '%' into NEW_VAL.

SELECT single * FROM <table name> into <work area> where FIELD3 LIKE NEW_VAL.

Hope this will help you.

Regards,

Smart Varghese

Former Member
0 Kudos

Hi

If field2 is a char field, then obviously FGD100 is < FGD200.

So your slecet query must be

Select *

from ZBOX

where field2 < 'FGD200'.

venkat_o
Active Contributor
0 Kudos

Hi Satya,

Select query should be like below

SELECT SINGLE *
  FROM zbox
 WHERE field2 <= 'FGD200'
   AND  field3 > 'FGD200'.

Thanks

Venkat

Former Member
0 Kudos

sloved