Top "Group-by" questions

GROUP BY is a command in the SQL relational database standard for collapsing a group of rows that share common field value(s) into a single row.

SQL Server Query for Rank (RowNumber) and Groupings

I have a table that has some columns: User, Category, Value And I want to make a query that will …

sql sql-server tsql group-by rank
SQL group by day, with count

I've got a log table in SQL Server that looks like this: CREATE TABLE [dbo].[RefundProcessLog]( [LogId] [bigint] IDENTITY(1,1) NOT …

sql sql-server group-by aggregate
Is it possible to use Aggregate function in a Select statment without using Group By clause?

So far I have written Aggregate function followed by Group By clause to find the values based on SUM, AVG …

sql sql-server sql-server-2005 group-by aggregate-functions
PostgreSQL MAX and GROUP BY

I have a table with id, year and count. I want to get the MAX(count) for each id and …

sql postgresql group-by max greatest-n-per-group
... where count(col) > 1

I have a table like this: +-----+-----+-------+ | id | fk | value | +-----+-----+-------+ | 0 | 1 | peter | | 1 | 1 | josh | | 3 | 2 | marc | | ... | ... | ... | I'd like …

sql oracle group-by having
In SQL, how to select the top 2 rows for each group

I have a table as following: NAME SCORE ----------------- willy 1 willy 2 willy 3 zoe 4 zoe 5 zoe 6 Here's the sample The aggregation …

mysql sql group-by greatest-n-per-group
linq distinct or group by multiple properties

How can I using c# and Linq to get a result from the next list: var pr = new List<…

c# linq group-by distinct
Why doesn't Oracle SQL allow us to use column aliases in GROUP BY clauses?

This is a situation I'm generally facing while writing SQL queries. I think that writing the whole column (e.g. …

sql oracle group-by alias
PostgreSQL query to count/group by day and display days with no data

I need to create a PostgreSQL query that returns a day the number of objects found for that day It's …

sql postgresql join group-by
Counting Using Group By Linq

I have an object that looks like this: Notice { string Name, string Address } In a List<Notice> I …

c# linq count group-by distinct