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(*) vs. SELECT SINGLE COUNT(*)

alejiandro_sensejl
Active Participant
0 Kudos

Hello gurus,

I simply want to check if at least one records of given where-clause already exists. Is there a difference between above mentioned statements?

Regards,

Alej

1 ACCEPTED SOLUTION

former_member194613
Active Contributor
0 Kudos

the correct solution is SELECT f1 UP TO 1 ROWS !!!!

You should not use COUNT(*), at least on some databases it will count all records fulfilling the condition.

YOU should not use SINGLE, because ... search top entries there are endless discussion on UP TO 1 ROWS and SINGLE

3 REPLIES 3

former_member194613
Active Contributor
0 Kudos

the correct solution is SELECT f1 UP TO 1 ROWS !!!!

You should not use COUNT(*), at least on some databases it will count all records fulfilling the condition.

YOU should not use SINGLE, because ... search top entries there are endless discussion on UP TO 1 ROWS and SINGLE

0 Kudos

Hello Siegfried,

thanks for your quick reply.

Could you provide some links to official documentation to prove these theses? I already searched, but I could finded any references to your assumptions.

Thanks in advance and best regards,

Alej

former_member194613
Active Contributor
0 Kudos

there is nothing officially published by SAP.

But my word should be enough , see here

http://www.dpunkt.de/suche/ergebnis?modus=einfach&author=&title=&keyword=boes

There you find source with exercise programs, run test case No. 381 and 382. I do not comment on the DB platforms but

I tried the 4 major ones.

Siegfried