Skip to content
Advertisement

Tag: dynamic-pivot

dynamic pivot SQL Query in DB2

I have table like below in DB2 where all these 3 columns are VARCHAR data type I need a dynamic PIVOT query which should select values for ABC_COL1 and ABC_COL2 in row format when FILE_NM filter is used as ABC.TXT The same query should select the values for XYZ_COL1, XYZ_COL2 and XYZ_COL3 in row format when FILE_NM filter is used

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:

Advertisement