I have a dataTable which has rows as shown in below image,
I would like to write groupby statement with select on that datatable for getting output as below,
select ApplicationName, count(*) from DataTableName
group by ApplicationName
where DataTableName
should be replaced by the actual name of your table in the database, and ApplicationName
should be replaced by the name of the column in that table that contains applicatin name
Simply this...
SELECT ApplicationName, COUNT(*) [Count]
FROM THETABLENAME
GROUP BY ApplicationName
or with ordering and filtering (where there is a duplication and order by the count)...
SELECT ApplicationName, COUNT(*) [Count]
FROM THETABLENAME
GROUP BY ApplicationName
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
Try this using
LINQ
inC#
Ref: Group by in DataTable Column sum