function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sarim AlaviSarim Alavi 

My count function is returning blank in SOQL


hi
i am stuck at very basic thing

if i am writing any query related to count i get null in count field

for example
select leadsource, count(id) Ce  from lead group by leadsource

returns
Leadsource    Ce
web                   ----
Phone               ---


where it should retrun count number

same with any other query

select Count(id) from account

or

SELECT COUNT(Id), COUNT(CampaignId)
FROM Opportunity

all blank no count numbers
please help


swathiswathi

HI,

 

No need of select count(id) from account. Just 

 

Integer i = [select count() from account];

 

It will return the number of records in account

pankaj.raijadepankaj.raijade

Swati is correct.

use just "count()".