SubSonic: Selecting all columns with an aggregate

531 Views Asked by At

How would you best handle constructing this SQL statement in SubSonic?

SELECT ac.*
       , SUM(pt.amount) AS totalPoints
FROM tbl_account AS ac
     INNER JOIN tbl_pointTracking AS pt ON ac.id = pt.accountID
GROUP BY pt.accountID
ORDER BY totalPoints DESC;

I know how to handle aggregates, but not sure how to handle aggregates with other columns.

Thanks all,
-Steve

1

There are 1 best solutions below

0
On

Here is the code which will help you to do so.

  gvGroup.DataSource = office.DB.Select(SubSonic.Aggregate.GroupBy("Designation"), SubSonic.Aggregate.Count("Designation")).From(Of office.Employee).ExecuteDataSet
        gvGroup.DataBind()