All Questions

784
votes
9answers
603463 views

Select first row in each GROUP BY group?

As the title suggests, I'd like to select the first row of each set of rows grouped with a GROUP BY. Specifically, if I've got a purchases table that looks like this: SELECT * FROM purchases; i...
628
votes
18answers
369705 views

Retrieving the last record in each group

There is a table messages that contains data as shown below: Id Name Other_Columns ------------------------- 1 A A_data_1 2 A A_data_2 3 A A_data_3 4 B B_data_...
164
votes
22answers
131448 views

What is the most efficient method to groupby on a JavaScript 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 ...
67
votes
1answers
1415 views

How to pivot a dataframe

What is pivot? How do I pivot? Is this a pivot? Long format to wide format? I've seen a lot of questions that ask about pivot tables. Even if they don't know that they are asking about pivot table...
711
votes
7answers
800209 views

Group by in LINQ

Let's suppose if we have a class like class Person { internal int PersonID; internal string car ; } Now I have a list of this class: List<Person> persons; Now this list can have ...
197
votes
15answers
211643 views

Error related to only_full_group_by when executing a query in MySql

I have upgraded my system and have installed MySql 5.7.9 with php for a web application I am working on. I have a query that is dynamically created, and when run in older versions of MySql it works fi...
753
votes
11answers
403092 views

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: QuantityB...
332
votes
14answers
359287 views

Get top 1 row of each group

I have a table which I want to get the latest entry for each group. Here's the table: DocumentStatusLogs Table |ID| DocumentID | Status | DateCreated | | 2| 1 | S1 | 7/29/2011 | | 3| ...
233
votes
11answers
231667 views

How to concatenate strings of a string field in a PostgreSQL 'group by' query?

I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table: ID COMPANY_ID EMPLOYEE 1 1 Anna 2 1 Bill 3 2 ...
636
votes
2answers
554040 views

Using group by on multiple columns

I understand the point of group by x But how does group by x, y work and what does it mean?

Previous Next