Category "group-by"

Python calculate increment rows till a condition

How to obtain the below result. Sample Data with Output Time To default is the column which is to be calculated. We need to get the increment number as Time to

Pandas Group by index Hour and keeping observation for each hour

I have a pandas dataframe containing one column and a datetime index, i need to group the data by hour and keep each obsevation (record) for each of the grouped

I need to group (tbl_types.name AS type) in a same row (postgres 14)

I need help with a select in postgres, I need to group X types into a single line, for example: type: multiple, trully, I need help on the type column SELECT tb

How to create nested array inside $group in MongoDB?

After some of the aggregation pipeline stages, my MongoDB Document has the following format: { "key": "A", "status": "To Do", "val": 4 }, {

Using Distinct in Aggregate Select query

I am using oracle DB. I have a Aggregated script. We found that some of the rows in the table are repeated, unwanted and hence, is not supposed to be added in

How to calculate frequency percentages for a table using SQL?

Let's say I have some data as follows: ID data fingers rating 001 hello y 0 002 hello n 0 003 bye n 0 004 hell

Two-part conditional sql statement

The statement below is querying a log table and I'm trying to get the max budget depending on the scenario if falls within. Error message: Expressions referenc

BigQuery standard SQL: how to group by an ARRAY field

My table has two columns, id and a. Column id contains a number, column a contains an array of strings. I want to count the number of unique id for a given arra

How to pivot a table in Presto?

Let be a table named data with columns time, sensor, value : I want to pivot this table on Athena (Presto) to get a new table like this one : To do so, one ca

How do I group values to an array for the same field value in jq?

I have json data that looks like [ { "session": "ffe887f3f150", "src_ip": "81.71.87.156" }, { "session": "fff42102e329", "src_ip": "143.19

SELECT list is not in GROUP BY clause and contains nonaggregated column .... incompatible with sql_mode=only_full_group_by

AM using MySQL 5.7.13 on my windows PC with WAMP Server Here my Problem is While executing this query SELECT * FROM `tbl_customer_pod_uploads` WHERE `load_id`

expression not in aggregate or GROUP BY columns

I have a table that contains the following columns: ProductID, ProductName, Price, CategoryID. The goal is to print all the details (ProductID, ProductName, Pri

Spark pivot groupby performance very slow

I am trying to pivot the dataframe of raw data size 6 GB and it used to take 30 minutes time (aggregation function sum): x_pivot = raw_df.groupBy("a", "b", "c"

How can we use group by keyword on PIVOT table having dynamic column joined with another table or alternative query of Pivot

I have 2 tables named tblDemo and tblSubDemo; tblDemo havve 2 columns _id and _name. tblSubDemo have 3columns, ID,Name, Demo_ID(it is the primary key of tblDemo

SQL group by in Subquery

I'm trying to get monthly production using group by after converting the unix column into regular timestamp. Can you please tell how to use group by here in the

Calculating Percentage value for a Group by value in Postgres

I want to calculate Percentage of a value in Group by. My Table data salesId salesAmount productName salesTyp ------- ----------- ----------- ----

R: Panel Data: calculating mean and median of variables based on date / dummy variable

So i am analysing fund panel data. I estimated a fixed effect model with double clustered error terms along the identification (ISIN) and (Date). Each fund has

Can list comprehensions make groups?

I have a list that looks like [(1,2,5),(2,10,13),(5,24,56),(1,8,10),(2,3,11)] How can I produce a dictionary by grouping by first element of tuples and find

Keeping time-series while grouping by season in xarray

I would like to have the winter (DJF) average for every year to plot a time-series. I know that I can group by season if I have a data array (DA). I don't know

GROUP BY + CASE statement

I have a working query that is grouping data by hardware model and a result, but the problem is there are many "results". I have tried to reduce that down to "