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

DISTINCT VALUES IN COLUMN

Former Member
0 Likes
813

I HAVE A COLUMN LIKE THIS:

111111

111111

222222

222222

333333

333333

I WANT TO GET THIS ONLY 1 TIME?

THANKS.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
792

after select if you want to do then...

delete adjacent duplicates by comparing field.

if you want to filter in select level

then use select distinct field

from mara

into itab.

thanks

vijay

I HAVE A COLUMN LIKE THIS:

111111

111111

222222

222222

333333

333333

I WANT TO GET THIS ONLY 1 TIME?

THANKS.

6 REPLIES 6
Read only

Former Member
0 Likes
792

Dear Liat,

You have not been very much clear.

What I gathered is that you are retreiving values from table with a column having those values. You can achieve with DISTINCT function of OpenSQL.

Eg: SELECT DISTINCT( field )

FROM table.

regards,

Deva.

Read only

Former Member
0 Likes
792

use select distinct

in your select query...

vijay

Read only

Former Member
0 Likes
793

after select if you want to do then...

delete adjacent duplicates by comparing field.

if you want to filter in select level

then use select distinct field

from mara

into itab.

thanks

vijay

Read only

0 Likes
792

sorry , this is internal table

Read only

0 Likes
792

Hi Liat,

1. DELETE ADJACENT DUPLICATES.

(see F1 help on this command )

2. try this code (just copy paste)

REPORT abc.

DATA : BEGIN OF itab OCCURS 0,

f(10) TYPE c,

END OF itab.

itab-f = '11111111'.

APPEND itab.

itab-f = '11111111'.

APPEND itab.

itab-f = '11111111'.

APPEND itab.

itab-f = '2222222'.

APPEND itab.

itab-f = '2222222'.

APPEND itab.

itab-f = '2222222'.

APPEND itab.

itab-f = '33333333'.

APPEND itab.

itab-f = '33333333'.

APPEND itab.

itab-f = '33333333'.

APPEND itab.

itab-f = '33333333'.

APPEND itab.

write 😕 '------ Before Delete Adjacent'.

LOOP AT itab.

WRITE 😕 itab-f.

ENDLOOP.

*----


sort itab by f. "------ IMPORTANT

delete adjacent duplicates from itab.

write 😕 '------ AFTER Delete Adjacent'.

LOOP AT itab.

WRITE 😕 itab-f.

ENDLOOP.

I hope it helps.

regards,

amit m.

Message was edited by: Amit Mittal

Message was edited by: Amit Mittal

Read only

0 Likes
792

then you can use

sort itab by field1.

DELETE ADJACENT DUPLICATES FROM ITab COMPARING field1.

try this..

vijay