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
 Transact-SQL (2005)
 Displaying data by taking columns union

Author  Topic 

sudha12345
Starting Member

47 Posts

Posted - 2009-04-25 : 02:43:36
i has one requirement that i want to display data b taking union of all

for ex

serverid customerid
p1 i1
p2 i2
p3 i3
p4 i4

select * from table where serverid = p1 and customerid =i1
union
select * from table where serverid = p2 and cusomerid = i2
union
select * from table where serverid =p3 and customerid = i3
union
select * from table where serverid =p4 and customerid = i4

is there any solution for this? if there please help me



Sudhakar

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2009-04-25 : 03:14:11
hi sudhakar,
wat u really want to achieve?
can u explain a little more..

using union will delete duplicate records..

tanx...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-25 : 03:14:45
Can you post some sample data with expected result?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sudha12345
Starting Member

47 Posts

Posted - 2009-04-25 : 03:21:01
quote:
Originally posted by soorajtnpki

hi sudhakar,
wat u really want to achieve?
can u explain a little more..

using union will delete duplicate records..

tanx...



i has a report that i will take different serverids and different
customerids.
so as i told there was data above, what we planned is to take
the serverids and customerids individully and compare the results between them.

for ex :
serverid customerid value
p1 i1 20
p2 i2 34
p3 i3 45
p4 i4 80

so we planned to take individually both the serverids and customerids
and then compare the data


Sudhakar
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2009-04-25 : 04:34:02
ok
then pls reply ur expected output

tanx..
Go to Top of Page
   

- Advertisement -