Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Sql , column header ..

Author  Topic 

sreekanth939
Starting Member

12 Posts

Posted - 2010-05-06 : 02:27:46
hi,
My table details r like this :

column1 column2 column3
A P1 1
A P2 2
A P3 3
B P1 4
B P2 5
B P3 6
D P1 7
E P2 8
F P3 9

i need a select query which givs reslut likethis:

if in where cond i put, column2=p1
column1 P1
A 1
B 4
D 7,

if in where cond i put, column2=p2

columns1 P2
A 2
B 5
E 8

help me pls!!!!!!!!!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-06 : 13:34:13
just do like

SELECT column1,column3
FROM Table
WHERE column2=@val


then pass required value through @val. @val should be declared as a parameter.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -