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 count problem

Former Member
0 Kudos

Hallow I doing a select statement for count but its not write I have a error what I doing wrong in this select

<b>SELECT orgeh COUNT( * ) AS orgeh

FROM pa0001

INTO TABLE count_itab

GROUP BY orgeh</b>

WHERE ( persg EQ '6' OR persg EQ '7' OR persg EQ '8' )

AND stell = 'A'

AND orgeh NE '00009999'

AND orgeh = 'Z'.

regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

1) remove as Orgeh

2) use group by at end of ur where condition

3 REPLIES 3

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

Try this code and kindly reward points by clicking the star on the left of reply,if it helps.

data : begin of count_itab,

orgeh type pa0001-orgeh,

count type i,

end of count_itab.

SELECT orgeh COUNT( * )

FROM pa0001

INTO TABLE count_itab

WHERE ( persg EQ '6' OR persg EQ '7' OR persg EQ '8' )

AND stell = 'A'

AND orgeh NE '00009999'

AND orgeh = 'Z'

GROUP BY orgeh.

Former Member
0 Kudos

Hi,

Try this

SELECT orgeh COUNT( * ) 
FROM pa0001
INTO TABLE count_itab
WHERE  persg IN ( '6' , '7' , '8'  )
AND stell = 'A'
AND orgeh NE '00009999'
AND orgeh = 'Z'
GROUP BY orgeh.

Y u have specified two conditions for a single field?

AND orgeh NE '00009999'

AND orgeh = 'Z'

Former Member
0 Kudos

1) remove as Orgeh

2) use group by at end of ur where condition