Category "pivot"

Pivot two columns

I have data that looks likes: stu_id course_name staff_name 1 Economics - 3 Kuzma, Brian 1 History Hulings, Kreg 1 IHS IB Lit of Americ Duncan, Amy 2 Marine Bi

How to group data with SQL

How do I group my Timestream data? The table looks simplified like this: point_delivery_number | measure_name | time | value ----------------

Transform a dataframe using pivot

I am trying to transform a dataframe using pivot. Since the column contains duplicate entries, i tried to add a count column following what's suggested here (Qu

Convert columns to rows in Spark SQL

I have some data like this: ID Value1 Value2 Value40 101 3 520 2001 102 29 530 2020 I want to take this data and convert in to a KV style pair instead ID Val

ERROR: Unsupported PIVOT column type: text

I'm trying to perform a PIVOT but getting an error. I'm trying to see which patients have more than one Interval session. The column is a text type. I attempted

GBQ Transpose Dynamically without Execute Immediate

Hi All trying to figure out a way to transpose data in columns dynamically. In the data the distinct number of Traits will increase/decrease. I know I can hardc

How to pivot between current day and previous days

I'm using Access SQL I have data that looks like this:- dealdate value 17-Apr-22 267 18-Apr-22 274 I'm trying to make the data look like this (there will only

Using Pivot to remove duplicated results adding new columns

I have the following table [_teste_calendario_Table] and when "Monstrengo" has the same value, I'd like to make a pivot, adding new columns "De1", "Ate1", "Ven

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

Pandas Pivot table - How compute the following default ratio?

I am able to compute the default rate in number (e.g, the percentage of customers falled into default), with the code below, getting the following output: impor

SQLITE PIVOT TABLE WITH COUNT

Can you help me plase ? I want a result like the table below with Sqlite . task_name status_code department 1 A START PUR 2 B START ENG 3 C FINISH ENG 4 D NOT

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

Transpose rows to columns in PostgreSQL?

Does any one know how to transpose rows to columns in PostgreSQL? For example I have the following table:- Period T1 T2 D

Pivot table sorting

I have a pivot table result as below : len MERCHANT_NAME MCC_CODE 0.0 58635982 742.0 7378 763.0 750 780.0 281 1

pandas: most elegant way to pivot table on pattern in name of columns

Given the following DataFrame: pd.DataFrame({ 'x': [0, 1], 'y': [0, 1], 'a_idx': [0, 1], 'a_val': [2, 3], 'b_idx': [4, 5], 'b_val': [6, 7], }) What

Unpivot multiple columns in Snowflake

I have a table that looks as follows: I need to unpivot the Rating and the Comments as follows: What is the best way to do this in Snowflake? Note: there are

SQL Transpose Rows to undefined number of columns

I have a table containing graduate ids, degree titles and graduation years. The table can contain any number of rows for each graduate. I would like to create