Combining multiple data points into a single data point. This usually is used in reference to SQL and usually to an aggregate function of some sort.

learn more… | top users | synonyms

0
votes
1answer
111 views

Nested query not recognize external table

i need to a query that show week by week the total amount of imports of any company and in addition add a ranking position depending on that amount. I've made this query but the problem is the inner ...
-2
votes
1answer
24 views

get average of rating using group by and then finally overall rating . Example below

Table is like: Name Category Rating Movie1 Horror 7 Movie2 Horror 10 Movie3 Horror 4 Movie4 Comedy 6.5 Movie5 Comedy 9 Movie6 comedy 3.5 I ...
3
votes
0answers
135 views

Is there a First() aggregate function in postgresql that returns the exact same type as the input?

Full question re-write I'm looking a First() aggregate function. Here I found something that almost works: CREATE OR REPLACE FUNCTION public.first_agg ( anyelement, anyelement ) RETURNS anyelement ...
1
vote
0answers
47 views

Join and aggregate result and insert blanks for missing appendants

Consider these two simplified tables: CREATE TABLE "sources" ( "id" serial NOT NULL, "name" text NOT NULL, CONSTRAINT "sources_pkey" PRIMARY KEY ("id") ); CREATE TABLE "values" ( ...
1
vote
0answers
83 views

MySQL aggregation count performance

I have a table with about 30 million records, and I'm doing a query where I can group by field Year and count the results for that year. The table structure looks like: id | year | amount The ...
1
vote
0answers
332 views

How to calculate running total based on dynamic values?

I need to calculate the running total in which the target column is changing along with the time. Its something which aws does. Charging based for only what you use. So how do I aggregate sum of ...
0
votes
0answers
13 views

Mongo - Fetch results sorted by the number of matching values in an array object

I have a mongo Database with collections such as : [{ _id : 'one', tags1 : ['A', 'B', 'C'], tags2 : ['D', 'E', 'F'] },{ _id : 'two', tags1 : ['A', 'Z'], tags2 : ['D', 'F', 'G', 'M'] } ...
0
votes
0answers
108 views

Select the top N products from each category, but where the merchant hasn't already been picked

this isn't the usual Select top N results from each category question - there's a little bit more to it. I have the Select top N query as follows: SELECT tmp.id, tmp.name, tmp.category_id, ...