Questions tagged [aggregation]

Aggregation is a relationship between two classes that is best described as a "has-a" and "whole/part" relationship.

Aggregation is a relationship between two classes that is best described as a "has-a" and "whole/part" relationship. It is a more specialized version of the association relationship. The aggregate class contains a reference to another class and is said to have ownership of that class. Each class referenced is considered to be part-of the aggregate class

3383 questions
33
votes
1 answer

Pandas - possible to aggregate two columns using two different aggregations?

I'm loading a csv file, which has the following columns: date, textA, textB, numberA, numberB I want to group by the columns: date, textA and textB - but want to apply "sum" to numberA, but "min" to numberB. data = pd.read_table("file.csv",…
marcus adamski
  • 373
  • 1
  • 3
  • 6
32
votes
7 answers

Is there an Oracle SQL query that aggregates multiple rows into one row?

I have a table that looks like this: A 1 A 2 B 1 B 2 And I want to produce a result set that looks like this: A 1 2 B 1 2 Is there a SQL statement that will do this? I am using Oracle. Related questions: Returning multiple rows from a single…
user128807
  • 10,447
  • 17
  • 53
  • 72
31
votes
10 answers

Aggregate bitwise-OR in a subquery

Given the following table: CREATE TABLE BitValues ( n int ) Is it possible to compute the bitwise-OR of n for all rows within a subquery? For example, if BitValues contains these 4 rows: +---+ | n | +---+ | 1 | | 2 | | 4 | | 3 | +---+ I would…
Daniel
  • 47,404
  • 11
  • 101
  • 179
31
votes
1 answer

C++ : Association, Aggregation and Composition

I'm beginning to study OOAD and I'm having difficulty finding a C++ code example that'd illustrate how Association, Aggregation and Composition are implemented programmatically. (There are several posts everywhere but they relate to C# or java). I…
Talha5389
  • 738
  • 1
  • 9
  • 22
30
votes
4 answers

SUM(subquery) in MYSQL

Basically, I am trying the following: SELECT m.col1, SUM(SELECT col5 FROM table WHERE col2 = m.col1) FROM table AS m This doesn't seem to work. Is there any solution?
Dänu
  • 5,791
  • 9
  • 43
  • 56
29
votes
6 answers

Custom aggregate function (concat) in SQL Server

Question: I want to write a custom aggregate function that concatenates string on group by. So that I can do a SELECT SUM(FIELD1) as f1, MYCONCAT(FIELD2) as f2 FROM TABLE_XY GROUP BY FIELD1, FIELD2 All I find is SQL CRL aggregate functions, but I…
28
votes
2 answers

Sorting after aggregation in Elasticsearch

I have docs with this structure: { FIELD1:string, FIELD2: [ {SUBFIELD:number}, {SUBFIELD:number}...] } I want to sort on the result of the sum of numbers in FIELD2.SUBFIELDs: GET myindex/_search { "size":0, "aggs": { "a1":…
maxv15
  • 1,057
  • 2
  • 9
  • 9
28
votes
3 answers

elasticsearch - Aggregation returns terms in key , but not the complete field, how can I get full field returned?

In the elasticsearch implementation , I have few simple aggregations on the basis of few fields as shown below - "aggs" : { "author" : { "terms" : { "field" : "author" , "size": 20, "order" : { "_term" : "asc" } …
dev123
  • 333
  • 1
  • 7
  • 14
25
votes
3 answers

SQL: How to filter after aggregation?

It is very easy to remove values that you don't want aggregated. For instance: SELECT department, SUM(sales) as "Total sales" FROM order_details GROUP BY department HAVING SUM(sales) > 1000; Which will exclude all sales with a value less than or…
Stumbler
  • 2,056
  • 7
  • 35
  • 61
23
votes
1 answer

Elasticsearch terms aggregation by strings in an array

How can I write an Elasticsearch terms aggregation that splits the buckets by the entire term rather than individual tokens? For example, I would like to aggregate by state, but the following returns new, york, jersey and california as individual…
Marieke
  • 263
  • 1
  • 2
  • 7
22
votes
1 answer

Django Postgresql ArrayField aggregation

In my Django application, using Postgresql, I have a model with an ArrayField of CharFields. I would like to know if there's a DB way to aggregate and get a list of all the strings in the table. For example: ['dog', 'cat'] ['dog'] ['cat'] would…
elynch
  • 2,150
  • 1
  • 18
  • 20
22
votes
1 answer

Performing Calculations on Multiple Metrics (Counts) in Kibana 4

I have a number of separate searches (elasticsearch) that produce simple metric visualisations. Each of these visualisations is a simple total (integer). That's easy enough. What I'd like to be able to do is work out the conversion rates between…
NickJHoran
  • 597
  • 4
  • 13
22
votes
5 answers

Client-Side Dynamic Removal of