hello
i am pretty new to asp.net and would like advice on how to best summarise data from an sql server database.
i have some data in a table, each record containing someones name and a 'type' field (contains positive or negative) among other stuff . i need to summarise the count of how many times a persons name appears in the table and display how many positive/negative entries there are.
i've used VB6 and VBA for ages and know how to do this by stepping through recordsets etc but want to know what the best approach is in ADO.NET, i'm still trying to get my head round data readers, datassets, data adapters, data tables etc.
any help is greatly appreciated
thanks
mickThis aggregation would probably be best left to your SQL engine of choice.
Based on the table:
PersonName varchar(50)
Active bit
With the values
PersonName Active
Tom 0
Tom 0
Tom 1
Jane 1
Jim 0
The query:
SELECT PersonName, COUNT(PersonName) HitCount, Active
FROM Person
GROUP BY PersonName, Active
ORDER BY PersonName
Should result in:
PersonName HitCount Active
Jane 1 1
Jim 1 0
Tom 2 0
Tom 1 1
From here, any tutorial on querying a database via SQL (a data reader should be fine) should apply.
thanks very much.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment