I want to create a report which displays the stats for data in a sql server table.The table columns I am interested in are searchTerm, dateadded.
Now I want to get the count of records for each searchterm but also display the earliest and latest dateadded for that searchterm.
for example:
select searchterm, count(*) as recCount from SearchTable order by searchterm.
will just give me the counts so I just need the dates and distinct records only.
Try this:
They GROUP BY will ensure that each row is distinct.