Skip to content

Tag: unpivot

Evaluate Multiple conditions for same row

I have to compare 2 different sources and identify all the mismatches for all IDs Source_excel table Source_dw table Expected result I have tried the below query but it is giving only one mismatch. Actual output I understand that case expression will only check the first satisfying condition. Is there any oth…

Stored procedure to unpivot

I have a table with these columns: Where fields from 01 to 50 are dates. I need to have a table like this: Where title code should be the column name from 01 to 50, data should be the value of that column in mytable I did this stored procedure by looking in older questions: but I’m getting a syntax

Convert rows to columns using PIVOT

I have a table named AmountList in SQL Server : where Primary key is ” UniqueCol1, UniqueCol2, AmountID ” and on the basis of AmountID I want to Pivot the results as: I am facing the challenge using Pivot because only Aggregate functions can be used but I need actual values of the fields. UPDATE: …

Replace row with Column Data in Sql Server

I have a table with some data and I was trying to Replace the Column with Row. The above Query gives me the result in one single row data. But I want the Result in below format I have tried the Pivot Operator using Derived Column but got confused during implementation. Please help to get the correct query. An…