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: 

Select Distinct not work.

Former Member
0 Kudos

hi Friends i go to se16n and see my Ztable ZGT_MICROPTO definition (and data):

CODIGO

VERSION

COMPONENTE

DESCRIPCION

ALTA

BAJA

BORRADO

P0011FI002PRUEBA 108.05.2013

P0021FI017PRUEBA 208.05.2013

P0031FI002PRUEBA 308.05.2013

P0041FI001PRUEBA 408.05.2013

P0051FI001PRUEBA 508.05.2013

P0051FI002PRUEBA 508.05.2013

P0061FI001PRUEBA 608.05.2013

P0071FI004PRUEBA 708.05.2013

P0071FI015PRUEBA 708.05.2013

P0071FI016PRUEBA 708.05.2013

P0081FI001PRUEBA 808.05.2013

P0091FI001PRUEBA 908.05.2013

i am interested in get only the Distinct values of the table.

i try:

SELECT DISTINCT CODIGO VERSION COMPONENTE DESCRIPCION ALTA BAJA BORRADO INTO CORRESPONDING FIELDS OF TABLE GT_MICROPTO FROM ZGT_MICROPTO.

but continue getting all the records(sames as the table).

Exist a way for get ONLY the distinct values of a Ztable?

Thanks

Chihuahua, Mexico.

Moderator Message - Read the ABAP online documentation or the F1 help before posting your query.

Message was edited by: Suhas Saha

6 REPLIES 6

matt
Active Contributor
0 Kudos

I think perhaps you misunderstand that nature of distinct. All the records in that table are distinct. DISTINCT used like this ensures that the record set returned from the database has no duplicate entries.

Check the keyword documentation again. http://help.sap.com/abapdocu_702/en/abapselect_clause_lines.htm#!ABAP_ALTERNATIVE_2@2@

Former Member
0 Kudos

Thanks for the answer, yes i not see the diference, (before) now i see that all records are differente.

Escuse me, for the basic question.

Thanks

former_member193464
Contributor
0 Kudos

By distinct what do you mean by it ? can you elaborate on it.....
as i see in your example every row is distinct , that is the reason it is picking all the rows ...

if you do not want to use distinct or want any three fields in the table to be distict  , you can select all data and then sort and delete adjacent duplicates from the internal table comparing those three fields....
hope it helps..

arindam_m
Active Contributor
0 Kudos

Hi,

Select DISTINCT is used to select records with DISTINCT KEY values from a table.

Say a Table has Key fields EMP_NO NAME and non-key field HOUSE

EMP_NO       NAME            HOUSE

120120         John               Villa

120123         John               Villa

120123         Mohan            Villa

All are distinct records so all will get selected Key Values (120120, John), (120123, John), (120123, Mohan). Same happens in your case also. Look into the KEY fields of your table to understand your selection better.

Cheers,

Arindam

Former Member
0 Kudos

Hello,

Simplest way to do this is by selecting all table, or fields that you want based on WHERE condition, after that you can do DELETE ... ADJACENT DUPLICATES COMPARING ...

You can combine fields as you want.

Respecto,

Paul.

0 Kudos

Select distinct

will fetch unique records based on select fields.

So you query is executing ok.

Another alternative.

Sort table

delete adjacent duplicates comparing fields...