|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Pivot SQL Statement in SQL SERVER 2000I have a table temp1 with the following data:
a b c d 10 11 888 991 10 11 888 992 How do I pivot this such that the output be 10 11 888 991 992 Thanks harish With the extremely limited information you've provided,
SELECT a,b,c,MIN(d),MAX(d) FROM temp1 GROUP BY a,b,c If you want a more complete answer, please provide a more complete question. http://www.aspfaq.com/5006 Show quote "harish" <harish.prabh***@gmail.com> wrote in message news:1131137736.316980.221230@g49g2000cwa.googlegroups.com... >I have a table temp1 with the following data: > > a b c d > 10 11 888 991 > 10 11 888 992 > > How do I pivot this such that the output be > > 10 11 888 991 992 > > Thanks > harish > Hey Thanks
But if i have more than 2 rows for one key (a,b,c) the this will not work. In that case how do I do it? > But if i have more than 2 rows for one key (a,b,c) the this will not See how helpful more information would have been?> work. > In that case how do I do it? http://www.aspfaq.com/2462Again, if you want a more useful answer, provide a more detailed question. See the link I posted in my previous response. harish (harish.prabh***@gmail.com) writes:
> But if i have more than 2 rows for one key (a,b,c) the this will not Books Online has a section on it:> work. > In that case how do I do it? Accessing and Changing Relational Data Advanced Query Concepts Transact-SQL Tips Cross-Tab Reports -- Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp |
|||||||||||||||||||||||