Skip to content
Advertisement

Tag: pivot

Transpose row to column in SQL Server

I have a table like below: The first row is the header. Now, I would like to transpose table into this I have tried unpivot but the result is not desired table. Thanks in advance, Answer I recommend using cross apply to unpivot and then aggregation: I much, much prefer this over pivot/unpivot. Why? APPLY implements a lateral join, which

Dynamic TSQL Pivot without aggregate function

I have a table like this (‘ExternalPersonRelationTable’) PersonId SubjectCode 4187 3 4187 278 4429 3 4429 4 4463 99 4464 174 4464 175 I want to rotate the data so that every person in the table gets a column and a TRUE/FALSE value for each subject code, i.e. a table like this: Code 4187 4429 4463 4464 3 TRUE TRUE

MySql pivot for unknown number of column headers

I have a MySql query which I would like to pivot dynamically, with Company names as column headers and the company financial fields as row headers. Currently I have this: which gives me this: Company TotalRevenue Overhead TotalJobCosts GrossProfit Chicago’s Best Construction 2098001 363750 1424420 673581 Jones Construction 4509458 1067008 2876568 1632890 and I wish to get something like this:

Oracle SQL Pivot with Conditions convert rows to columns

I have the a table ITEM_SF with the following data I want to convert the data into Columns with a few conditions: My desired result is to show Charges, Discounts , Amount Paid and Tax Charges include (BookFees, HealthFees,RegistrationFees,SSCFees,TuitionFees,GeneralFees) Charges , Discount is Sum of ITEM_AMT where ITEM_TYPE_CD =’W’ FeesPaid is Sum of ITEM_AMT where ITEM_TYPE_CD =’P’ VAT is Sum

Dynamic columns using pivot

I have a table that looks like this: Main table id bomname styleid 1 bom1 101 2 bom2 102 3 bom3 103 this is detail table Id bomId bomKey bomValue 1 1 part cllr 2 1 unit kg 3 1 qty 123 4 1 part body 5 1 unit kg 6 1 qty 456 7 2 part slm 8 2

Advertisement