Skip to content
Advertisement

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 other way I can check all the condition? Answer

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

Transform Columns to Rows dynamically using T-SQL

I have the following table where I need to transform Columns to Rows tbl_Survey: I need to have the following result: To have this result I used the following code: But, my Quest_1, Quest_2, Quest_3 values could potentially be changed / or even added a new once… Are there ways to code them, so it can be used for any

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: Added my attempt for the

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. Answer Assuming

Advertisement