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

Query on Select Statement

Former Member
0 Likes
797

Dear All,

I have a small query on the Select Statement. If there are 2 identical rows and if i am retrieving them using the Select Statement, then will the select statement retrieves both the rows which are identical or only the first possible occurence? Pls help me out in this.

Thanks,

Sirisha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
779

Hi,

That depends on the statement u use. If u use, 'SELECT' statment, u can retrieve all the records which are identical with one or few fields. For that, u need to put the output INTO A TABLE.

Ex. 1

data : int_ekko type table of ekko with header line,

fs_ekko type ekko.

select * from ekko into table int_ekko where ebeln = '6361003191'.

Here, int_ekko is an internal table contains all records whose EBELN = 63610003191.

2) If u use 'SELECT SINGLE', then it will retrieve only the first record out of all the records who satisfy the condition EBELN = 6361003191.

Ex 2:

select single * from ekko into fs where ebeln = '63610003191'.

'fs' is not a table, just of type structure. so contains only one record.

Hope it help u..

Kindly reward points if hepful

Regards,

Shanthi.

Edited by: Shanthi on Mar 4, 2008 8:17 AM

6 REPLIES 6
Read only

Former Member
0 Likes
779

Dear Sirisha,

that depends on ur select query. If u put SELECT SINGLE it retrieves first one only. IF u put SELECT * it retrieves all the data.

Regards,

Ajay

Read only

Former Member
0 Likes
779

hi,

when u rare using select single it is going to select single records

if with normal select then all the records will be selected

Read only

Former Member
0 Likes
779

It depends on the where condition u mention.

If you want to retirve MATNR 10002 from MARA.

If you write

SELECT * FROM MARA
                INTO TABLE itab
                WHERE matnr = '0000010002'.

This will retrieve suppose if MATNR has two rows also. As it is a key firkld it wont have two rows.

Specify the table structure explain with a sample so that I can help you out.

Read only

dhruv_shah3
Active Contributor
0 Likes
779

Hi,

Only the first Occurrence.

HTH,

regard,

Dhruv Shah

Read only

Former Member
0 Likes
780

Hi,

That depends on the statement u use. If u use, 'SELECT' statment, u can retrieve all the records which are identical with one or few fields. For that, u need to put the output INTO A TABLE.

Ex. 1

data : int_ekko type table of ekko with header line,

fs_ekko type ekko.

select * from ekko into table int_ekko where ebeln = '6361003191'.

Here, int_ekko is an internal table contains all records whose EBELN = 63610003191.

2) If u use 'SELECT SINGLE', then it will retrieve only the first record out of all the records who satisfy the condition EBELN = 6361003191.

Ex 2:

select single * from ekko into fs where ebeln = '63610003191'.

'fs' is not a table, just of type structure. so contains only one record.

Hope it help u..

Kindly reward points if hepful

Regards,

Shanthi.

Edited by: Shanthi on Mar 4, 2008 8:17 AM

Read only

Former Member
0 Likes
779

Hi,

If you use SELECT SINGLE it will select only one row and that too the first row,pertaining to the condition given in WHERE clause.

Otherwise it will fetch all the duplicate row entries as well.

So what you can do is, use

DELETE ADJACENT DUPLICATES FROM itab.

where itab is the internal table into which the data is fetched thru the SELECT statement.

Reward if helpful.

Regards.