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

Select Count

Former Member
0 Likes
4,550

I am assuming this is basically use for finding the number of entries in a DB table...any other comon uses?

Should sy-dbcnt be checked when using this?

Thank-You

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,447

HI Tom,

Yes, that is its primary usage. To be precise, it gives the number of matches for the current where clause.

no need to check. It essentially does the same.

Regards,

Ravi

10 REPLIES 10
Read only

alex_m
Active Contributor
0 Likes
1,447

SY-DBCNT will give u no of entries return by your select statement, if u put select * the sy-dbcnt will contain how many entries in DB table.

Read only

Former Member
0 Likes
1,447

Hi,

sy-dbcnt - total no of database records .

Regards,

Smithi

Read only

Former Member
0 Likes
1,447

Hi,

Sy-Dbcnt is used only for count the total no of records in db table.

No,

not for any orther uses.

Regards,

Sreevani

Read only

Former Member
0 Likes
1,447

Hello TOM,

<b>SY-DBCNT - DB operations, number of table lines processed</b>

Vasanth

Read only

Former Member
0 Likes
1,448

HI Tom,

Yes, that is its primary usage. To be precise, it gives the number of matches for the current where clause.

no need to check. It essentially does the same.

Regards,

Ravi

Read only

0 Likes
1,447

So checking sy-dbcnt is same as COUNT.

So my basic question is still what would I use COUNT for?

Read only

0 Likes
1,447

Hi

Sy-dbcnt will give the no. of records fetched from the database.

i.e Number of <b>processed table rows</b>

SY-DBCNT

SQL statements set the content of SY-DBCNT to the number of database lines processed. With SELECT loops in Open SQL, SY-DBCNT is set after the ENDSELECT statement. In Native SQL, SY-DBCNT is set after the ENDEXEC statement.

DELETE sets SY-DBCNT to the number of lines deleted.

FETCH sets SY-DBCNT to the number of lines already read by the current cursor.

INSERT sets SY-DBCNT to the number of lines inserted.

MODIFY sets SY-DBCNT to the number of lines processed.

UPDATE sets SY-DBCNT to the number of lines changed.

COUNT

<b>count</b> gives the total number of records present in the database table

Apart from that no other use as such

Hope this clears your doubt.

reward if useful

Regards,

Saumya

Read only

0 Likes
1,447

Hi,

count Returns the number of lines selected.

sy-dbcnt DB operations, number of table lines processed

Regards,

Sruthi

Read only

0 Likes
1,447

Saumya, Thanks you say..count gives the total number of records present in the database table, Apart from that no other use as such.

Where does it give the total no of records? in sy-dbcnt, because I check this without using COUNT.

Thanks everybody all feedback is appreciated.

Read only

0 Likes
1,447

Hi Tom,

Finally u got a answer, example. Count function u can use for particular col name.

SELECT COUNT( CARRID )

INTO COUNT FROM SPFLI

WHERE

CITYTO = 'NEW YORK'.

WRITE: / COUNT.

For performance concern not advaisable to use COUNT statement.