pivot

Unpivot an Excel matrix/pivot-table?

∥☆過路亽.° 提交于 2020-01-27 08:40:28
问题 Is there a quick way to "unpivot" an Excel matrix/pivot-table (in Excel or elsewhere), without writing macros or other code ? Again, I can write code (C# or VBA or whatever) that does that myselfs. I want to know if it is possible to do it without code, quickly ? E.g. I need to convert this permission matrix (given as Excel-table/matrix) into this half-normalized table (so I can insert it into a SQL database): e.g. in SQL I could do it like this: CREATE TABLE dbo.T_DocumentMatrix ( [Function]

MS SQL Server pivot table with subquery in column clause

坚强是说给别人听的谎言 提交于 2020-01-27 07:46:29
问题 Im sure this is a simple technique although I can't find an answer so far! I have TIMESTAMP | POINTNAME | VALUE 2012-10-10 16:00:00 AHU01 20 2012-10-10 16:00:00 AHU02 25 2012-10-10 16:00:15 AHU01 26 2012-10-10 16:00:15 AHU02 35 etc... ( for approx 800 POINTNAMES) with many pointnames I dont want to list each one in the 'IN' clause of the pivot 'FOR' (as syntax given below) definition but would like to use perhaps a subquery. So what I would like is all the POINTNAME values as columns with A

MS SQL Server pivot table with subquery in column clause

本小妞迷上赌 提交于 2020-01-27 07:46:25
问题 Im sure this is a simple technique although I can't find an answer so far! I have TIMESTAMP | POINTNAME | VALUE 2012-10-10 16:00:00 AHU01 20 2012-10-10 16:00:00 AHU02 25 2012-10-10 16:00:15 AHU01 26 2012-10-10 16:00:15 AHU02 35 etc... ( for approx 800 POINTNAMES) with many pointnames I dont want to list each one in the 'IN' clause of the pivot 'FOR' (as syntax given below) definition but would like to use perhaps a subquery. So what I would like is all the POINTNAME values as columns with A

MS SQL Server pivot table with subquery in column clause

本秂侑毒 提交于 2020-01-27 07:45:31
问题 Im sure this is a simple technique although I can't find an answer so far! I have TIMESTAMP | POINTNAME | VALUE 2012-10-10 16:00:00 AHU01 20 2012-10-10 16:00:00 AHU02 25 2012-10-10 16:00:15 AHU01 26 2012-10-10 16:00:15 AHU02 35 etc... ( for approx 800 POINTNAMES) with many pointnames I dont want to list each one in the 'IN' clause of the pivot 'FOR' (as syntax given below) definition but would like to use perhaps a subquery. So what I would like is all the POINTNAME values as columns with A

Remove the string after '-' and group remaining string and pivot column

两盒软妹~` 提交于 2020-01-25 07:59:05
问题 Here is my actual data in Excel, which I am successfully able to read in DataGridView in C# Windows Application. Test | Energy | --------------------- C018-3L-1 | 113 | C018-3L-2 | 79 | C018-3L-3 | 89 | C018-3L-4 | 90 | C018-3L-5 | 95 | C021-3T-1 | 115 | C021-3T-2 | 100 | But now I want this data in DataGridView in below Format from excel file: Test |Energy-1|Energy-2|Energy-3 | ------------------------------------ C018-3L |113 |79 |89 | C018-3L |90 |95 |NULL | C021-3T |115 |100 |NULL | Here

R | pivot_wider() | How to handle duplicates in “values_from” column

笑着哭i 提交于 2020-01-25 07:27:50
问题 I have a dataframe: ID questions value A 1 8 A 1.1 7 A 1.2 -3 B 1 7 B 4.3 7 ... ... ... I'm trying to pivot the data on "questions" such that the data frame will look like this: ID 1 1.1 1.2 4.3 A 8 7 -3 NA B ... ... ... 7 ... Using the pivot_wider() function, I ran into an error: df %>% pivot_wider(names_from = question, values_from = value) Values in `rating` are not uniquely identified; output will contain list-cols. * Use `values_fn = list(rating = list)` to suppress this warning. * Use

How to create two column output from a single column

前提是你 提交于 2020-01-24 15:29:08
问题 I am guessing this is a noob question so please bear with me. I have a column in a mySQL table that contains both first name and last name plus other data (see table below). fid | uid | value 5 | 1 | John 6 | 1 | Doe 7 | 1 | some other data 5 | 2 | Jane 6 | 2 | Doe 7 | 2 | some other data What I would like to do is create a query where I split out the first and last names into their own columns for reporting purposes (like shown below). First Name | Last Name John | Doe Jane | Doe I haven't

Is there a way to pivot a customer ID and a their most recent order dates?

北慕城南 提交于 2020-01-24 13:12:11
问题 I have a query that gives me all customer's and their last three order dates. EX: CustomerId DateOrdered 167 2006-09-16 01:25:38.060 167 2006-09-21 13:11:53.530 171 2006-08-31 15:19:22.543 171 2006-09-01 13:30:54.013 171 2006-09-01 13:34:36.483 178 2006-09-04 11:36:19.983 186 2006-09-05 12:50:27.153 186 2006-09-05 12:51:08.513 I want to know if there is a way for me to pivot it to display like this: [CustomerId] [Most Recent] [Middle] [Oldest] '167' '2006-09-21 13:11:53.530' '2006-09-16 01:25

Is there a way to pivot a customer ID and a their most recent order dates?

非 Y 不嫁゛ 提交于 2020-01-24 13:12:09
问题 I have a query that gives me all customer's and their last three order dates. EX: CustomerId DateOrdered 167 2006-09-16 01:25:38.060 167 2006-09-21 13:11:53.530 171 2006-08-31 15:19:22.543 171 2006-09-01 13:30:54.013 171 2006-09-01 13:34:36.483 178 2006-09-04 11:36:19.983 186 2006-09-05 12:50:27.153 186 2006-09-05 12:51:08.513 I want to know if there is a way for me to pivot it to display like this: [CustomerId] [Most Recent] [Middle] [Oldest] '167' '2006-09-21 13:11:53.530' '2006-09-16 01:25

Table column split to two columns in sql?

你离开我真会死。 提交于 2020-01-23 23:11:06
问题 In sql server, I have once column in the table, i want to make the column in two column, in the other table [new table]. Can you help me. ------------------------ Type ------------------------ UserDefine UserDefine AutoGenerate AutoGenerate UserDefine ------------------------- The above is my column in one of my table now i want to make the column in two like UserDefine and Autogenerate column in different table ----------------------------------- UserDefine | AutoGener | --------------------