Question
I'm new to Simple.Data. But i'm having a really hard time finding out how to do a 'group by'.
What I want is very basic.
Table looks like:
+________+
| cards |
+________+
| id |
| number |
| date |
+________+
I want the equivalent of this query:
select * from (select * from cards order by date desc) as m group by number;
So I get the latest record, 1 for each number.
Any help is appreciated, even if I'm barking up the wrong tree
Thanks
Solution
Simple.Data infers GROUP BY clauses based on your use of aggregates.
db.Cards.All().Select(db.Cards.Number, db.Cards.Date.Max());
will give you the max date for each number.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow