|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
transpose a tablehi guys,
how do you transpose a table? I don't need the actual sql codes, but I want to know Algorithm and steps and how you would do it. I went to an interview and tech guy asked me this question and I don't know how to answer him, that really bothers me.
http://www.aspfaq.com/2462
Show quote "Britney" <britneychen_2***@yahoo.com> wrote in message
news:%238HXbzJtFHA.3236@TK2MSFTNGP09.phx.gbl... > hi guys, > how do you transpose a table? I don't need the actual sql codes, but I > want to know Algorithm and steps and how you would do it. I went to an > interview and tech guy asked me this question and I don't know how to > answer him, that really bothers me. > > > > > what is PIVOT?
Show quote "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:uQSEW7JtFHA.460@TK2MSFTNGP15.phx.gbl... > http://www.aspfaq.com/2462 > > > > > > "Britney" <britneychen_2***@yahoo.com> wrote in message > news:%238HXbzJtFHA.3236@TK2MSFTNGP09.phx.gbl... >> hi guys, >> how do you transpose a table? I don't need the actual sql codes, but I >> want to know Algorithm and steps and how you would do it. I went to an >> interview and tech guy asked me this question and I don't know how to >> answer him, that really bothers me. >> >> >> >> >> > >
http://dictionary.reference.com/search?q=transpose
Show quote "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
news:uFWJZSKtFHA.3640@tk2msftngp13.phx.gbl... >> what is PIVOT? > > What is transpose? >
Thanks, I know the definition of the word transpose. I figured the article
would have made it at least somewhat clear that pivot is what she is looking for. :-( Back in the early 90's, I bluffed my way through a lot questions by simply
answering: "Sure, that can be done using a Windows API function call". Of course, that was the correct answer 99% of time (although probably not the best answer). For SQL Server, the answer "I would use T-SQL to do that." works. If the interviewer is not a DBA or database developer, then they probably won't ask a follow up. Just to cover your ass, you can later go to BOL and lookup the details. ;-) Show quote "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:uqtOscUtFHA.276@TK2MSFTNGP10.phx.gbl... >> http://dictionary.reference.com/search?q=transpose > > Thanks, I know the definition of the word transpose. I figured the > article would have made it at least somewhat clear that pivot is what she > is looking for. :-( > A "pivot" is Microsoft's parlance for a generalization of what's
commonly called a cross-tab report. Pivot is what I would assume you mean by "transpose". If you meant something different then please explain. SQL Server 2005 supports PIVOT directly as a clause in the SELECT statement. In SQL 2000 however you some standard SQL queries to achieve the same thing. Try out the examples that Aaron posted - it's easier to demonstrate it than to describe it. -- David Portas SQL Server MVP -- |
|||||||||||||||||||||||