pivot

Excel Pivot

余生颓废 提交于 2020-01-11 13:15:09
问题 I am an excel newb, wondering if excel has built in functionality to do the following. Turn this data: Name | Activity | Option Bob | Monday Activities | Golf Bob | Tuesday Activities| Kayak Marge | Monday Activities | Spa John | Tuesday Activities| Soccer Liz | Tuesday Activities| Spa Into: Name | Monday Activities | Tuesday Activities Bob | Golf | Kayak Marge | Spa | John | | Soccer Liz | | Spa 回答1: Pivot tables allow you to manipulate and display numerical data, not strings such as "kayak"

Dynamic pivot in oracle sql - Procedure

坚强是说给别人听的谎言 提交于 2020-01-11 11:19:12
问题 I got a solution to dynamic pivot from this post . Now I want to implement the below statements in an oracle procedure. clear columns COLUMN temp_in_statement new_value str_in_statement SELECT DISTINCT LISTAGG('''' || myLetter || ''' AS ' || myLetter,',') WITHIN GROUP (ORDER BY myLetter) AS temp_in_statement FROM (SELECT DISTINCT myLetter FROM myTable); SELECT * FROM (SELECT myNumber, myLetter, myValue FROM myTable) PIVOT (Sum(myValue) AS val FOR myLetter IN (&str_in_statement)); Thanks in

Dynamic pivot in oracle sql - Procedure

你。 提交于 2020-01-11 11:19:11
问题 I got a solution to dynamic pivot from this post . Now I want to implement the below statements in an oracle procedure. clear columns COLUMN temp_in_statement new_value str_in_statement SELECT DISTINCT LISTAGG('''' || myLetter || ''' AS ' || myLetter,',') WITHIN GROUP (ORDER BY myLetter) AS temp_in_statement FROM (SELECT DISTINCT myLetter FROM myTable); SELECT * FROM (SELECT myNumber, myLetter, myValue FROM myTable) PIVOT (Sum(myValue) AS val FOR myLetter IN (&str_in_statement)); Thanks in

MySQL, multiple rows to separate fields

放肆的年华 提交于 2020-01-11 08:52:48
问题 I have a MySQL table with fields and data such as follows; PartNumber Priority SupName a1 0 One a2 0 One a2 1 Two a3 0 One a4 1 Two a5 2 Three I am trying to create a view where the parts that have multiple rows are combined into a single row, and into separate fields such as Ideally This; PartNumber Sup1 Sup2 Sup3 a1 One NULL NULL a2 One Two NULL a3 One NULL NULL a4 Two NULL NULL a5 Three NULL NULL Or I can live with this PartNumber Sup1 Sup2 Sup3 a1 One NULL NULL a2 One Two NULL a3 One NULL

Not able to formulate query to combine different row values in single row using pivot table

大憨熊 提交于 2020-01-11 07:20:14
问题 Below is the actual table In the table above: 1) FEID is the examination ID which remains same for one exam, like ist semester examination of particular class. So it will remain same for all rows in above table as it consists of data of single exam always. 2) To store result of single student, marks for each subject are entered in each row. So if there are 5 subjects in a class,For each student marks of 5 subjects will be stored in 5 separate rows with marks obtained in each subject 3) Result

query for horizontal layout of mysql data

ε祈祈猫儿з 提交于 2020-01-11 04:14:09
问题 I have a table (delvery_dates) with the following fields: del_id, del_date, del_ProductID My normal query produces 2014-08-23 | 25 2014-08-23 | 32 2014-08-23 | 14 2014-08-23 | 15 2014-08-23 | 56 2014-08-23 | 34 2014-08-27 | 32 2014-08-27 | 11 2014-08-27 | 19 2014-08-27 | 35 etc I would like a query that outputs in the following format: del_date, del_ProductID-1, del_ProductID-2, del_ProductID-3, del_ProductID-4 .. up to 6 2014-08-23 25 32 14 15 2014-08-27 32 11 19 35 I've seen somewhere about

Using SQL to transpose/flatten XML structure to columns

核能气质少年 提交于 2020-01-10 19:35:31
问题 I am using SQL Server (2008/2012) and I know there are similar answers from lots of searching, however I can't seem to find the appropriate example/pointers for my case. I have an XML column in a SQL Server table holding this data: <Items> <Item> <FormItem> <Text>FirstName</Text> <Value>My First Name</Value> </FormItem> <FormItem> <Text>LastName</Text> <Value>My Last Name</Value> </FormItem> <FormItem> <Text>Age</Text> <Value>39</Value> </FormItem> </Item> <Item> <FormItem> <Text>FirstName<

How do I use SQL to PIVOT a table without an aggregate and without knowing column values?

时光总嘲笑我的痴心妄想 提交于 2020-01-07 09:49:11
问题 I am working on a legacy database and need to develop a SQL query to give to a customer. As a legacy database, it was not designed with this type of query in mind. I've simplified the two tables I need to select from to make an easier to understand example. I have a "long table", and need to make it "wide". I have tried working with PIVOT but have encountered two issues: There is nothing to aggregate- it's just a simple matrix transformation. I don't know the number of columns I need to add

Prepared Statement: How to join header

て烟熏妆下的殇ゞ 提交于 2020-01-07 06:52:20
问题 I've got 2 tables where i want to join the header and the first column within an prepared statement. I've got managed to join the column, but how to join the header? Table1 : ID |Name ---------- 1 | A 2 | B 3 | C 4 | D 5 | E Table2 : TeamA|TeamB|Won|Lost -------------------- 1 | 2 | 5 | 3 1 | 3 | 2 | 4 1 | 4 | 9 | 1 2 | 5 | 5 | 5 3 | 1 | 2 | 4 Result-Matrix: | A | B | C | D | E ---------------------------- A | 0 | 2 | -2 | 8 | 0 B | 0 | 0 | 0 | 0 | 0 C | -2 | 0 | 0 | 0 | 0 SQL Fiddle 回答1: In

Pivot table error

浪子不回头ぞ 提交于 2020-01-07 04:49:06
问题 WHY, why, why? Do I get an error: "Msg 325, Level 15, State 1, Line 17 Incorrect syntax near 'PIVOT'. You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel." For this query? WITH Offnet7 AS ( SELECT disposition.dispositiondesc, interaction.dispositionid, DATEPART(wk,interaction.ibegintime) as iWeek FROM interaction INNER JOIN disposition ON interaction.reasonid = disposition.dispositionid