cancel
Showing results for 
Search instead for 
Did you mean: 

sql to count the no. of entries

Former Member
0 Kudos

Hi all,

I know that we can count the no. of entries with

SY-DBCNT,

but besides this, can I directly use sql statement, e.g. select count...

to count the no. of entries?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Lakshmant1
Active Contributor
0 Kudos

Hi Macy,

Yes you can use the SQL statement and it is the advised methid to find the count of the records.

Thanks

Lakshman

Answers (6)

Answers (6)

MariaJoãoRocha
Contributor
0 Kudos

Hi,

You can:

Select count(*)

from table

where ....

Check the sy-dbcnt.

Regards,

Maria João Rocha

Former Member
0 Kudos

Hi Macy,

We can use like this.

SELECT count(*) into l_var1

from <db table>

where <cond>.

I think the above statement solves your problem.

Regards,

Ganesh N

ralf_geiger
Explorer
0 Kudos

Hi Macy,

I would also suggest using SY-DBCNT or DESCRIBE <itab> ... if possible. When using COUNT(*) in a database select it always bypasses the buffer and we should avoid that if possile

Regards,

Ralf

Former Member
0 Kudos

Hi,

You can use DESCRIBE table itab into va_count.

this will give you the number of rows.

Lokesh

Pls. reward appropriate points

abdul_hakim
Active Contributor
0 Kudos

Hi

It is advisable to use sy-dbcnt to count,your COUNT(*) will pass another request from appl.server to database.server..Performance!!

My choice is sy-dbcnt..

Abdul

former_member188685
Active Contributor
0 Kudos

Hi,

You can use select count to count the no of entries.

thanks

vijay