Category Archives for SQL

Select Query that Includes count(*)

There are times when you might need to include a count of records in a simple select query.

select *,
(select count(*) from alison.ActivityLog) as rowCount
from alison.ActivityLog

Some databases will require that you list the fields rather than using * to designate all fields:

Select CurrentPage, StatusCode, ErrorCode,
(select count(*) from alison.ActivityLog) as rowCount
from alison.ActivityLog