Quantcast
Channel: Query for Transpose Data
Browsing latest articles
Browse All 24 View Live

Query for Transpose Data

How To rename a column names Dynamically as version1,varsion2 as etc

View Article



Query for Transpose Data

How to Renmae a column names dynamically

View Article

Query for Transpose Data

Thank you

View Article

Query for Transpose Data

Here  you go CREATE TABLE Foo (  ItemName CHAR(2),  Ver TINYINT,  qty INT); INSERT INTO Foo  VALUES('I1', 1,10); INSERT INTO Foo VALUES('I1', 2,15); INSERT INTO Foo VALUES('I2', 1,18); INSERT INTO Foo...

View Article

Query for Transpose Data

And also i have one identity column in the given table. Now check the query pls

View Article


Query for Transpose Data

TRY THIS,declare @TempTable table (ItemName varchar(20), Version int, Quantity int); insert into @TempTable values('I1',1,10) insert into @TempTable values('I1',2,15) insert into @TempTable...

View Article

Query for Transpose Data

I used (you see that) the test data you have posted above, there is no miracle.Best Regards,Uri Dimant SQL Server MVP,http://sqlblog.com/blogs/uri_dimant/ MS SQL optimization: MS SQL Development and...

View Article

Query for Transpose Data

But I am Getting output like thisItemName         1                    2l1                 800.0000             NULLl2                  810.0000            NULL l1                     NULL...

View Article


Query for Transpose Data

It works just fine CREATE TABLE Foo (  ItemName CHAR(2),  Ver TINYINT,  qty INT); INSERT INTO Foo VALUES('I1', 1,10); INSERT INTO Foo VALUES('I1', 2,15); INSERT INTO Foo VALUES('I2', 1,18); INSERT INTO...

View Article


Query for Transpose Data

But it showing duplicate entries as followsItemName [1]     [2]I1               10     nullI1               null      8 l2                 8      nulll2               null       9But i need Output as...

View Article

Query for Transpose Data

Take a look at example I posted above how to use dynamic pivoting.Best Regards,Uri Dimant SQL Server MVP,http://sqlblog.com/blogs/uri_dimant/ MS SQL optimization: MS SQL Development and Optimization MS...

View Article

Query for Transpose Data

thanks. But version is not fixed how can i dynamically write it.

View Article

Query for Transpose Data

SELECT ItemName   ,MAX(CASE WHEN Version =1 THEN Quantity END),MAX(CASE WHEN Version =2 THEN Quantity END)FROM tbl GROU BY ItemName  Best Regards,Uri Dimant SQL Server...

View Article


Query for Transpose Data

If the data is  as follows ItemName   Version QuantityI1                     1        10I1                      2        15I2                      1          8I2                       2          9I...

View Article

Query for Transpose Data

You can build dynamic sql , see example CREATE TABLE Foo (  foo_type CHAR(1) PRIMARY KEY,  foo_value INT); INSERT INTO Foo VALUES('A', 1); INSERT INTO Foo VALUES('B', 2); INSERT INTO Foo VALUES('C',...

View Article


Query for Transpose Data

thats ok but i want the result without duplicatelike the query given by Uri Dimant. but this is static.The needed output is ItemName Qty1  Qty2I1               10      11I2                8...

View Article

Query for Transpose Data

Deleted

View Article


Query for Transpose Data

thanks. but the sp returns duplicate records for each versionwithout dynamic sp the records are correct but when i use the above dynamic sp the records duplicated like belowItemName [1]     [2]I1...

View Article

Query for Transpose Data

Deleted

View Article

Query for Transpose Data

thats fine but if version is more than fixed how can i dynamically write it

View Article

Query for Transpose Data

Deleted

View Article


Query for Transpose Data

what is the logic to find out ItemName .

View Article


Query for Transpose Data

SELECT Version,SUM(CASE WHEN Version=1 THEN Quantity END) Quantity_1,SUM(CASE WHEN Version=2 THEN Quantity END) Quantity_2FROM tbl GROUP BY VersionBest Regards,Uri Dimant SQL Server...

View Article

Query for Transpose Data

hi,  I have a table with the following dataItemName   Version QuantityI1                     1        10I2                      2        15I3                      1          8I4                       2...

View Article
Browsing latest articles
Browse All 24 View Live




Latest Images