Application Development and Automation 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: 
Read only

Select Query Scenario

kesavadas_thekkillath
Active Contributor
0 Likes
891

Hi all,

I have a select query scenario.

For example in a ztable

I have two fields A and B

it holds records like

A B

3 5

2 10

7 12

if my input is 4

I wrote a query like

select * from ztab where ( a <= input and b >= input ).

But its not working

The problem is its picking both the record

3 5

2 10

but my output should be

3 5

Hope its clear ..

I know that this could be acheived using a select and a delete from itab.

But i need to acheive this through single select.

Any ideas ..

1 ACCEPTED SOLUTION
Read only

Manohar2u
Active Contributor
0 Likes
861

Why 3 5 and whynot 2 10? on what basis you need 3 5? will that logic works with just select?

9 REPLIES 9
Read only

Manohar2u
Active Contributor
0 Likes
862

Why 3 5 and whynot 2 10? on what basis you need 3 5? will that logic works with just select?

Read only

0 Likes
861

Hi i'll explain with the real values

my input is 123456789011234

but its fetching

100000 199999

100000 199999

Hope its clear now.

Actually it must not pick any data.

Read only

Subhankar
Active Contributor
0 Likes
861

Check the length of the data element for both field (a and b)

Read only

Former Member
0 Likes
861

Hi,

Just a hunch: are all three fields in your example (A, B, input) numeric ? If they are character fields, then the two fetched records nicely match your WHERE clause.

Rgds,

Mark

Read only

0 Likes
861

Yes you are right.

All three are of type c.

Me too was looking around this.

but after the select when i give

DELETE lt_cdv_params[] WHERE to_bankkey < input.

still it doesnt work.

hope so i should change the data type.

Any ways to do without changing the data type ?

Read only

Former Member
0 Likes
861

Hi,

If the data comes from a Z table and the fields are numeric by nature (as the name "bankkey" might imply), then I would really recommend adapting the data type in the table, making the fields numeric. Working around the data type in your code (which technically you coudl do by a MOVE from the C field to a numeric field) would be clumsy and you'd have to do it in every program thet accesses this data.

Regards,

Mark

Read only

0 Likes
861

Done by changing the type to NUMC and Solved

Read only

Former Member
0 Likes
861

Hi,

Use SELECT SINGLE statement then you will get first record.

Read only

0 Likes
861

1)I cannot use select single , may contain multiple records.

2)Data types are same for both

Should i go for sub query ?