Click here to Skip to main content
15,897,518 members
Home / Discussions / Database
   

Database

 
Questionquery needed to swap column values for duplicate Pin
xcavin1-Dec-09 13:26
xcavin1-Dec-09 13:26 
AnswerRe: query needed to swap column values for duplicate Pin
_Damian S_1-Dec-09 13:48
professional_Damian S_1-Dec-09 13:48 
GeneralRe: query needed to swap column values for duplicate Pin
xcavin1-Dec-09 13:59
xcavin1-Dec-09 13:59 
GeneralRe: query needed to swap column values for duplicate Pin
_Damian S_1-Dec-09 14:05
professional_Damian S_1-Dec-09 14:05 
GeneralRe: query needed to swap column values for duplicate Pin
Luc Pattyn1-Dec-09 15:06
sitebuilderLuc Pattyn1-Dec-09 15:06 
GeneralRe: query needed to swap column values for duplicate Pin
_Damian S_1-Dec-09 15:58
professional_Damian S_1-Dec-09 15:58 
QuestionTransposing rows and Columns in SQL Pin
Leo Smith1-Dec-09 8:05
Leo Smith1-Dec-09 8:05 
AnswerRe: Transposing rows and Columns in SQL Pin
Niladri_Biswas1-Dec-09 15:54
Niladri_Biswas1-Dec-09 15:54 
Hi,
This kind of problems are called Cross Tab Queries and can be solved easily using PIVOTING (a feature from SQL SERVER 2005+).

Here is an example

Pivots with Dynamic Columns in SQL Server 2005[^]

You can even look into

a) Cross-Tab reports in SQL Server 2005[^]

b)Using PIVOT and UNPIVOT[^]


In Sql Server 2000, Pivoting was achieved using Case along with an aggregate function.

Look here

Pivot Table Data in SQL Server 2000 and 2005[^]


However, a few days back I gave a similar kind of answer in Bytes. U can have a look

Month to month yearly results[^]

Hope this helps
Smile | :)

Niladri Biswas

Questionuser import Pin
AndyInUK1-Dec-09 6:30
AndyInUK1-Dec-09 6:30 
AnswerRe: user import Pin
loyal ginger1-Dec-09 6:44
loyal ginger1-Dec-09 6:44 
GeneralRe: user import Pin
AndyInUK1-Dec-09 22:08
AndyInUK1-Dec-09 22:08 
GeneralRe: user import Pin
loyal ginger2-Dec-09 3:43
loyal ginger2-Dec-09 3:43 
AnswerRe: user import Pin
Shameel1-Dec-09 6:56
professionalShameel1-Dec-09 6:56 
GeneralRe: user import Pin
loyal ginger1-Dec-09 7:01
loyal ginger1-Dec-09 7:01 
GeneralRe: user import Pin
AndyInUK1-Dec-09 22:08
AndyInUK1-Dec-09 22:08 
GeneralRe: user import Pin
Shameel2-Dec-09 6:53
professionalShameel2-Dec-09 6:53 
GeneralRe: user import Pin
AndyInUK3-Dec-09 0:34
AndyInUK3-Dec-09 0:34 
GeneralRe: user import Pin
Shameel4-Dec-09 6:59
professionalShameel4-Dec-09 6:59 
AnswerTSQL for creating SQL Server Logins and Users Pin
David Mujica1-Dec-09 7:44
David Mujica1-Dec-09 7:44 
GeneralRe: TSQL for creating SQL Server Logins and Users Pin
AndyInUK1-Dec-09 22:08
AndyInUK1-Dec-09 22:08 
QuestionString search problem in SQL Server Pin
hvgyufg28fh38tyr78hf1-Dec-09 1:57
hvgyufg28fh38tyr78hf1-Dec-09 1:57 
AnswerRe: String search problem in SQL Server [modified] Pin
Niladri_Biswas1-Dec-09 2:04
Niladri_Biswas1-Dec-09 2:04 
GeneralRe: String search problem in SQL Server Pin
hvgyufg28fh38tyr78hf1-Dec-09 2:27
hvgyufg28fh38tyr78hf1-Dec-09 2:27 
AnswerRe: String search problem in SQL Server Pin
The Man from U.N.C.L.E.1-Dec-09 2:28
The Man from U.N.C.L.E.1-Dec-09 2:28 
GeneralRe: String search problem in SQL Server Pin
hvgyufg28fh38tyr78hf1-Dec-09 2:30
hvgyufg28fh38tyr78hf1-Dec-09 2:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.