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

regarding select query

Former Member
0 Likes
1,017

hi to all,

i want to fetch 5 records from standard table,

in that table ,for these 5 fields some records are repetetive.

if i fetch those recordds by using select query,only the first record is only coming,n remaining repetetive records are not coming.

i want to fetch all the reocrds.

ex: in std table 121 records are there,after fetching those data into internal table,only 68 records are coming.

plz suggest me,

regards

satya

9 REPLIES 9
Read only

Former Member
0 Likes
988

Use the addition... [DISTINCT]

Effect

If SINGLE is not specified and if columns does not contain only aggregate expressions, the resulting set has multiple lines. All database lines that are selected by the remaining additions of the SELECT command are included in the resulting list. If the ORDER BY addition is not used, the order of the lines in the resulting list is not defined and, if the same SELECT command is executed multiple times, the order may be different each time. A data object specified after INTO can be an internal table and the APPENDING addition can be used. If no internal table is specified after INTO or APPENDING, the SELECT command triggers a loop that has to be closed using ENDSELECT.

If multiple lines are read without SINGLE, the DISTINCT addition can be used to exclude duplicate lines from the resulting list. If DISTINCT is used, the SELECT command circumvents SAP buffering. DISTINCT cannot be used in the following situations:

If a column specified in columns has the type STRING, RAWSTRING, LCHAR or LRAW

If the system tries to access pool or cluster tables and single columns are specified in columns.

Notes

When specifying DISTINCT, note that this requires the execution of sort operations in the database system, and the SELECT statement therefore bypasses the SAP buffer.

Read only

Former Member
0 Likes
988

based on ur select qurey it select the data from database.

selct <fieldlist>

from <dbtable>

into table <itab name>

where <condition>

Madhavi

Read only

Former Member
0 Likes
988

Hi..

Use select DISTINCT

this will to the job for you

SELECT <OTHER FIELDS FROM BSIS> DISTINCT(ZOUNR) FROM BSIS

WHERE <CONDITION>.

BEST WAY TO DO SO....

SORT INT by ZUONR.

DELETE ADJACENT DUPLICATES from int COMPARING ZUONR.

REWARD if USEFUL

GAURAV J.

Edited by: GAURAV on Feb 4, 2008 7:53 AM

Read only

0 Likes
988

you should try this instead of your query

it will select all records from dbtab to your itab

select <field>

from <dbtab name>

into table <itab name>

where <condition>

this statement is really good performance wise

reward if useful

keep rockin

vivek

Read only

Former Member
0 Likes
988

Hi,

What is ur Standard table ?

Use select * from tablename...

or

Select the unique key field in that standard table.

then it will select all the records, incase same record also.

Thanx

bgan.

Read only

Former Member
0 Likes
988

Hi,

I think it is because you are not selecting the key fields in your selecton. To solve this problem make sure that you are selecting all the key fields( evenif these fields not requred for you also) or try to select all the fields ie, select *.

ie,

Select * from <DB> into correpondin fields of table <itab>.

or

Select <ALL key fields> < other required fields> from <DB> into correpondin fields of table <itab>.

Make sure that your ITAB is compatable to accomaodate all the fields including key fields.

Read only

0 Likes
988

hi to all,

i checked all of these suggestions,but i didnt get,

plz suggest me.

Read only

Former Member
0 Likes
988

Hi,

Can you paste ur code here?

Regards,

Satish

Read only

Former Member
0 Likes
988

hai,

plz check this ,

in ur table find primary key field

then use

select <field>

from <dbtab name>

into table <itab name>

where <primary key field > in parameters [or]

select-options.