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: 

How to select record value from a particular field name?

Former Member
0 Kudos

hi all, currently i need to do a select for etc,

field name (gender)

i need to retrieve the distinct values for gender which consist of female or male and do a count on it. Was figuring out how to do it. Thx~

1 ACCEPTED SOLUTION

former_member223537
Active Contributor
0 Kudos

SELECT COUNT(DISTINCT(GENDER)) FROM ZTABLE where AGE = 25.
10 REPLIES 10

former_member223537
Active Contributor
0 Kudos

SELECT COUNT(DISTINCT(GENDER)) FROM ZTABLE where AGE = 25.

gopi_narendra
Active Contributor
0 Kudos
data : IT_TAB1 type table of ZTAB.
data : IT_TAB2 type table of ZTAB.

data : N_M type I.
data : N_F type I.

select * from <ZTAB> into table IT_TAB1 where gender = 'MALE'.
describe table IT_TAB1 lines N_M. "N_M gives the no of males

select * from <ZTAB> into table IT_TAB2 where gender = 'FEMALE'.
describe table IT_TAB2 lines N_F. "N_F gives the no of females 

Regards

Gopi

Former Member
0 Kudos

hi Prashant Patil ,

if let say my field for gender is a dynamic request whereby i allow user to select the fieldname first before coming to this screen. how should i do it? or anyone who knows? thx

Former Member
0 Kudos

Hi,

Try this code.

Select-options: <s_gender> for <datatype>.

Select count ( distinct (gender) ) from <dbtab> where gender in s_gender.

Former Member
0 Kudos

hi Gopi Narendra,

the code u gave me can it read dynamically from user input?

0 Kudos

Instead of hardcoding, use the input parameter.

data : IT_TAB type table of ZTAB.

data : N type I.

parameters : p_gender type ZTAB-GENDER.

select * from <ZTAB> into table IT_TAB where gender = p_gender.
describe table IT_TAB lines N. "N gives the no of males or females according to the input p_gender 

Regards

Gopi

ZTAB is the table which contains the data of the field GENDER

Edited by: Gopi Narendra on Dec 26, 2007 11:43 AM

Former Member
0 Kudos

hi Gopi,

the ZTAB u declare is a value table name or?

Former Member
0 Kudos

u try this one....

SELECT COUNT(DISTINCT(GENDER)) FROM table where <condition>.

kesavadas_thekkillath
Active Contributor
0 Kudos

if u want hte count only..then use the functional module

CATT_GET_TABLE_ENTRIES

pass the table name to param2

then the where caluse to the rest.

Former Member
0 Kudos

hi all, let me go further into my exact scenario. for etc, my gender value which consist of female and male is inside a value table. so how should my select statement go about?