MySQL Query GROUP BY day / month / year

Is it possible to make a simple query to count how many records I have in a determined period of time like a year, month, or day, having a TIMESTAMP field, like: SELECT COUNT(id) FROM stats WHERE record_date.YEAR = 2009 GROUP BY record_date.YEAR Or even: SELECT COUNT(id) FROM stats GROUP BY record_date.YEAR, record_date.MONTH To have … Read more

Most efficient method to groupby on an array of objects

What is the most efficient way to groupby objects in an array? For example, given this array of objects: [ { Phase: “Phase 1”, Step: “Step 1”, Task: “Task 1”, Value: “5” }, { Phase: “Phase 1”, Step: “Step 1”, Task: “Task 2”, Value: “10” }, { Phase: “Phase 1”, Step: “Step 2”, Task: “Task … Read more

Group By Multiple Columns

How can I do GroupBy multiple columns in LINQ Something similar to this in SQL: SELECT * FROM <TableName> GROUP BY <Column1>,<Column2> How can I convert this to LINQ: QuantityBreakdown ( MaterialID int, ProductID int, Quantity float ) INSERT INTO @QuantityBreakdown (MaterialID, ProductID, Quantity) SELECT MaterialID, ProductID, SUM(Quantity) FROM @Transactions GROUP BY MaterialID, ProductID 14 … Read more

Group by in LINQ

Let’s suppose if we have a class like: class Person { internal int PersonID; internal string car; } I have a list of this class: List<Person> persons; And this list can have multiple instances with same PersonIDs, for example: persons[0] = new Person { PersonID = 1, car = “Ferrari” }; persons[1] = new Person … Read more