Top "Aggregate-functions" questions

Aggregate functions are a subset of SQL functions that compute a single value from multiple input rows, mostly used in `SELECT` queries with a `GROUP BY` clause.

LINQ aggregate and group by periods of time

I'm trying to understand how LINQ can be used to group data by intervals of time; and then ideally aggregate …

c# linq aggregate-functions
SQL comma-separated row with Group By clause

I have the following query: SELECT Account, Unit, SUM(state_fee), Code FROM tblMta WHERE MTA.Id = '123' GROUP …

sql sql-server sql-server-2005 aggregate-functions sql-server-group-concat
Return as array of JSON objects in SQL (Postgres)

I have the following table MyTable: id │ value_two │ value_three │ value_four ────┼───────────┼─────────────┼──────────── 1 │ a │ A │ AA 2 │ a │ A2 │ AA2 3 │ b │ …

sql arrays json postgresql aggregate-functions
MySQL: How to SUM() a TIMEDIFF() on a group?

So I've got a set of results that looks something like this: SELECT User_ID, StartTime, EndTime, TIMEDIFF(EndTime, StartTime) …

sql mysql aggregate-functions
PostgreSQL: running count of rows for a query 'by minute'

I need to query for each minute the total count of rows up to that minute. The best I could …

sql postgresql datetime aggregate-functions window-functions
Postgres CASE in ORDER BY using an alias

I have the following query which works great in Postgres 9.1: SELECT users.id, GREATEST( COALESCE(MAX(messages.created_at), '2012…

sql postgresql sql-order-by aggregate-functions case
Select distinct from usercolumn and minimum value of dates for each field in usercolumn

I have some data like this but more than 1500000 records and more than 700 users: usercolumn , datecolumn\ a1 , 1998/2/11\ a2 , 1998/3/11\ a1 , 1998/2/15\ a4 , 1998/4/14\ …

sql distinct aggregate-functions minimum
truncated LISTAGG string

I'm using Oracle 11g r2 and I need to concatenate strings (VARCHAR2, 300) from multiple rows. I'm using LISTAGG which works …

sql oracle oracle11g aggregate-functions oracle11gr2
SqlAlchemy: count of distinct over multiple columns

I can't do: >>> session.query( func.count(distinct(Hit.ip_address, Hit.user_agent)).first() TypeError: distinct() …

postgresql count sqlalchemy distinct aggregate-functions