aggregate-functions Questions
5
Solved
I have 2 tables:
Table person with columns: person_id, person_name
Table pet with columns: pet_id, owner_id, pet_name
person data:
1, 'John'
2, 'Jill'
3, 'Mary'
pet data:
1, 1, 'Fluffy'
2, 1, 'Bus...
Southing asked 7/10, 2019 at 10:0
4
Solved
Is there a way to apply an aggregate function to all (or a list of) columns of a dataframe, when doing a groupBy? In other words, is there a way to avoid doing this for every column:
df.groupBy("c...
Utgardloki asked 23/11, 2015 at 23:40
4
Solved
This sql code throws an
aggregate functions are not allowed in WHERE
SELECT o.ID , count(p.CAT)
FROM Orders o
INNER JOIN Products p ON o.P_ID = p.P_ID
WHERE count(p.CAT) > 3
GROUP BY o.ID...
Leary asked 8/1, 2014 at 9:34
5
Solved
I have an application where I find a Sum() of a database column for a set of records and later use that sum in a separate query, similar to the following (made up tables, but the idea is the same):...
Ambiguous asked 27/8, 2013 at 1:21
8
Solved
Suppose you have result set such as:
DATE ID cost
---------------------------------------
01/01/2011 1 10
01/01/2011 1 10
01/01/2011 2 10
01/01/2011 2 10
I want a way to sum the values ...
Kekkonen asked 11/5, 2011 at 22:18
6
Solved
How do I get a column that is the sum of the preceding values of another column?
Sydney asked 9/4, 2011 at 17:19
9
Solved
I'm trying to understand how LINQ can be used to group data by intervals of time; and then ideally aggregate each group.
Finding numerous examples with explicit date ranges, I'm trying to group by...
Xanthippe asked 13/1, 2012 at 19:40
3
Solved
Hei!
How can I create an aggregate function to obtain a list of the aggregate values.
given :
key value
Andrei 1
Andrei 2
Andrei 3
Mihai 4
Mihai 5
Mihai 6
I want
key list
Andrei 1,2,3
Mihai ...
Shive asked 20/2, 2012 at 9:22
10
I am trying to understand GROUP BY (new to oracle dbms) without aggregate function.
How does it operate?
Here is what i have tried.
EMP table on which i will run my SQL.
SELECT ename , sal
FROM em...
Bachman asked 19/11, 2013 at 14:46
3
Solved
I have a 'vendors' table that looks like this...
**company itemKey itemPriceA itemPriceB**
companyA, 203913, 20, 10
companyA, 203914, 20, 20
companyA, 203915, 25, 5
companyA, 203916, 10, 10
It has...
Tavia asked 30/1, 2022 at 13:26
2
Solved
I know you can get the average, total, min, and max over a subset of the data using a window function. But is it possible to get, say, the median, or the 25th percentile instead of the average with...
Utoaztecan asked 25/9, 2016 at 4:20
6
I am trying to group some records into 5-, 15-, 30- and 60-minute intervals:
SELECT AVG(value) as "AvgValue",
sample_date/(5*60) as "TimeFive"
FROM DATA
WHERE id = 123 AND sample_date >= 3/21/2...
Mattoid asked 22/3, 2012 at 0:39
1
Solved
I'm constructing quite complex query, where I try to load users with their aggregated points altogether with their rank. I found the RANK() function that could help me to achieve this but can't get...
Saval asked 10/10, 2016 at 8:53
3
Solved
I need to write a sql query on the table such that the result would have the group by column along with the aggregated column with comma separators.
My table would be in the below format
|``````...
Plenipotentiary asked 14/6, 2011 at 14:15
4
Solved
I have the following query:
SELECT
Account,
Unit,
SUM(state_fee),
Code
FROM tblMta
WHERE MTA.Id = '123'
GROUP BY Account,Unit
This of course throws an exception because the Code is not in th...
Infect asked 16/9, 2011 at 18:12
7
I have one table named GUYS(ID, NAME, PHONE), and I need to add a count of how many guys have the same name, and at the same time show all of them. So I can't group them.
Example:
ID NAME PHONE
1 J...
Quadruplet asked 23/11, 2010 at 18:50
4
Solved
I have a table author_data:
author_id | author_name
----------+----------------
9 | ernest jordan
14 | k moribe
15 | ernest jordan
25 | william h nailon
79 | howard jason
36 | k moribe
...
Cryptonym asked 28/3, 2014 at 20:45
4
Solved
I can't do:
>>> session.query(
func.count(distinct(Hit.ip_address, Hit.user_agent)).first()
TypeError: distinct() takes exactly 1 argument (2 given)
I can do:
session.query(
func.cou...
Xanthochroism asked 24/5, 2013 at 6:31
5
Solved
I have a data frame with several columns; some numeric and some character. How to compute the sum of a specific column? I’ve googled for this and I see numerous functions (sum, cumsum, rowsum, rowS...
Overindulge asked 12/3, 2012 at 23:22
2
I am trying to get average rating of an associated Model "Rating" of Model "User" using sequelize.
sequelize.sync({logging: false}).then(()=>{
return Model.Rating.findAll({
attributes: [[Sequ...
Florrieflorry asked 27/1, 2020 at 9:57
3
Solved
I need to get as a result from query fully structured JSON.
I can see in postgres that there are some built in functions that may be useful.
As an example I created a structure as follows:
-- T...
Cherice asked 14/2, 2017 at 9:57
8
Solved
I'm finding a way to aggregate strings from different rows into a single row. I'm looking to do this in many different places, so having a function to facilitate this would be nice. I've tried solu...
Strauss asked 30/11, 2012 at 4:57
2
Solved
This could be incredibly simple by the documentation is quite on it. Is there a way to aggregate columns via multiplication operator in postgresql. I know i can do count(column) or sum(column), but...
Fuze asked 7/2, 2014 at 8:57
5
Solved
According to the docs, common sense and some manuals on common SQL the max function returns only maximum value. So the correct way to select the row(s) with the maximum value is a subquery:
select...
Dermatoplasty asked 12/7, 2017 at 14:51
8
Solved
I want to select data from a table in MySQL where a specific field has the minimum value, I've tried this:
SELECT * FROM pieces WHERE MIN(price)
Please any help?
Pneumodynamics asked 13/11, 2012 at 7:50
© 2022 - 2025 — McMap. All rights reserved.