Questions tagged [aggregate]

Aggregate refers to the process of summarizing grouped data, commonly used in Statistics.

Aggregate refers to the process of summarizing grouped data, commonly used in Statistics. Typically this involves replacing groups of data with single values (e.g. sum, mean, standard deviation, etc.). In SQL databases and data manipulation libraries such as in , this is accomplished with the use of GROUP BY and aggregate functions.

Documentation:

8256 questions
23
votes
5 answers

Any reason for GROUP BY clause without aggregation function?

I'm (thoroughly) learning SQL at the moment and came across the GROUP BYclause. GROUP BY aggregates or groups the resultset according to the argument(s) you give it. If you use this clause in a query you can then perform aggregate functions on the…
Niels Bom
  • 8,728
  • 11
  • 46
  • 62
23
votes
7 answers

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 NULL, [LogDate] [datetime] NOT NULL, [LogType] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, …
Chris McCall
  • 10,317
  • 8
  • 49
  • 80
23
votes
1 answer

pandas' transform doesn't work sorting groupby output

Another pandas question. Reading Wes Mckinney's excellent book about Data Analysis and Pandas, I encountered the following thing that I thought should work: Suppose I have some info about tips. In [119]: tips.head() Out[119]: total_bill tip …
r_31415
  • 8,752
  • 17
  • 74
  • 121
22
votes
5 answers

SQL distinct and count

I have a query where I want to get distinct dates, the phone numbers associated with those dates, and a count of the phone numbers per date. For example, I have a database with dates and phone numbers and I want the result to be 9/2005 …
Ryan George
22
votes
4 answers

How to load extensions into SQLite?

I need a standard deviation function in SQLite. I have found one here: http://www.sqlite.org/contrib?orderby=date but its part of an extension file to SQLite. I've never installed one of these before and I don't know how to. I found this existing…
Chucky
  • 1,701
  • 7
  • 28
  • 62
22
votes
1 answer

ODCIAggregateMerge without parallel_enabled

These are quotes from Oracle docs: [Optional] Merge by combining the two aggregation contexts and return a single context. This operation combines the results of aggregation over subsets in order to obtain the aggregate over the entire set. This…
piezol
  • 915
  • 6
  • 24
22
votes
1 answer

Apply function conditionally

I have a dataframe like this: experiment iter results A 1 30.0 A 2 23.0 A 3 33.3 B 1 313.0 B 2 323.0 B 3 350.0 .... Is there a way to tally results by applying a…
Oliver
  • 3,592
  • 8
  • 34
  • 37
21
votes
3 answers

Best way to convert Dictionary into single aggregate String representation?

How would I convert a dictionary of key value pairs into a single string? Can you do this using LINQ aggregates? I've seen examples on doing this using a list of strings, but not a dictionary. Input: Dictionary map = new…
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
21
votes
1 answer

C# About IEnumerable.Aggregate

I did some tests about IList.Aggregate(), but the answer does not make sense to me. List Data1 = new List { 1,0,0,0,0}; var result = Data1.Aggregate((total, next) => total + total); The result is 16. I expected it to be 32. Can…
retide
  • 1,170
  • 1
  • 13
  • 31
21
votes
2 answers

Why can an aggreggate struct be brace-initialized, but not emplaced using the same list of arguments as in the brace initialization?

It seems like this code: #include #include struct bla { std::string a; int b; }; int main() { std::vector v; v.emplace_back("string", 42); } could be made to work properly in this case, but it doesn't (and I…
rubenvb
  • 74,642
  • 33
  • 187
  • 332
21
votes
1 answer

Aggregate all columns of data.table, without having to reference them by name

I'd like to do the equivalent of the following, but with data.table's "by": dt <- data.table(V1=rnorm(100), V2=rnorm(100), V3=rnorm(100), ... group=rbinom(100,2,.5)) dt.agg <- aggregate(dt, by=list(dt$group), FUN=mean) I know that…
stackoverflax
  • 1,077
  • 3
  • 11
  • 25
21
votes
3 answers

CQRS sagas - did I understand them right?

I'm trying to understand sagas, and meanwhile I have a specific way of thinking of them - but I am not sure whether I got the idea right. Hence I'd like to elaborate and have others tell me whether it's right or wrong. In my understanding, sagas are…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
21
votes
5 answers

SQL JOIN, GROUP BY on three tables to get totals

I've inherited the following DB design. Tables are: customers --------- customerid customernumber invoices -------- invoiceid amount invoicepayments --------------- invoicepaymentid invoiceid paymentid payments -------- paymentid …
Nick
20
votes
4 answers

django aggregate or annotate

This is a very stupid thing, I know, but I just don't seem to get the handle on Django aggregate and annotate functions. I have a very simple set of models: Events, Areas and Types. An event has foreign keys pointing to Area and Type. I would…
freethrow
  • 1,068
  • 3
  • 20
  • 34
20
votes
2 answers

STRING_AGG aggregation result exceeded the limit of 8000 bytes error

I need to combine texts by group. I found a function called STRING_AGG. select c.id , c.bereichsname , STRING_AGG(j.oberbereich,',') oberBereiches from stellenangebote_archiv as j join bereiche as c on j.bereich_id = c.id group by c.id,…
Eren G.
  • 455
  • 1
  • 5
  • 14