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.

SQL select only rows with max value on a column

I have this table for documents (simplified version here): +------+-------+--------------------------------------+ | id | rev | content | +------+-------+--------------------------------------+ | 1 | 1 | ... | | 2 | 1 | ... | | 1 | 2 | ... | | 1 | 3 | ... | +------+-------+…

mysql sql aggregate-functions greatest-n-per-group groupwise-maximum
SQL Server: Difference between PARTITION BY and GROUP BY

I've been using GROUP BY for all types of aggregate queries over the years. Recently, I've been reverse-engineering some code …

sql-server tsql aggregate-functions window-functions
Function to Calculate Median in SQL Server

According to MSDN, Median is not available as an aggregate function in Transact-SQL. However, I would like to find out …

sql-server tsql aggregate-functions median
SELECTING with multiple WHERE conditions on same column

Ok, I think I might be overlooking something obvious/simple here... but I need to write a query that returns …

mysql sql aggregate-functions where-clause
How to SUM and SUBTRACT using SQL?

I am using MySQL and I have two tables: master_table ORDERNO ITEM QTY stock_bal ITEM BAL_QTY Master …

mysql sql aggregate-functions
must appear in the GROUP BY clause or be used in an aggregate function

I have a table that looks like this caller 'makerar' cname | wmname | avg --------+-------------+------------------------ canada | zoro | 2.0000000000000000 spain | luffy | 1.00000000000000000000 …

sql group-by aggregate-functions postgresql-9.1
How to sum data.frame column values?

I have a data frame with several columns; some numeric and some character. How to compute the sum of a …

r dataframe sum aggregate-functions
LISTAGG in Oracle to return distinct values

I am trying to use the LISTAGG function in Oracle. I would like to get only the distinct values for …

sql oracle aggregate-functions listagg
The SQL OVER() clause - when and why is it useful?

USE AdventureWorks2008R2; GO SELECT SalesOrderID, ProductID, OrderQty ,SUM(OrderQty) OVER(PARTITION BY SalesOrderID) AS 'Total' ,AVG(OrderQty) OVER(PARTITION …

mysql sql sql-server aggregate-functions clause