05-09-2013 12:09 AM
hi Friends i go to se16n and see my Ztable ZGT_MICROPTO definition (and data):
CODIGO
VERSION
COMPONENTE
DESCRIPCION
ALTA
BAJA
BORRADO
P001 | 1 | FI002 | PRUEBA 1 | 08.05.2013 | ||
P002 | 1 | FI017 | PRUEBA 2 | 08.05.2013 | ||
P003 | 1 | FI002 | PRUEBA 3 | 08.05.2013 | ||
P004 | 1 | FI001 | PRUEBA 4 | 08.05.2013 | ||
P005 | 1 | FI001 | PRUEBA 5 | 08.05.2013 | ||
P005 | 1 | FI002 | PRUEBA 5 | 08.05.2013 | ||
P006 | 1 | FI001 | PRUEBA 6 | 08.05.2013 | ||
P007 | 1 | FI004 | PRUEBA 7 | 08.05.2013 | ||
P007 | 1 | FI015 | PRUEBA 7 | 08.05.2013 | ||
P007 | 1 | FI016 | PRUEBA 7 | 08.05.2013 | ||
P008 | 1 | FI001 | PRUEBA 8 | 08.05.2013 | ||
P009 | 1 | FI001 | PRUEBA 9 | 08.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
05-09-2013 5:09 AM
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@
05-09-2013 5:52 AM
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
05-09-2013 5:11 AM
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..
05-09-2013 5:24 AM
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
05-09-2013 9:58 AM
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.
05-09-2013 12:07 PM
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...