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 one column data into two Columns

Author  Topic 

sudha12345
Starting Member

47 Posts

Posted - 2009-04-25 : 01:21:40
I have a table wih 1 column an 5 rows. The data in the column is
like 1st row p1:i1
2nd row p2:i2
3rd row p3:i3
4th row p4:i4
5th row p5:i5

and i want the output as 2 columns
serverid customerid
p1 i1
p2 i2
p3 i3
p4 i4
p5 i5

the single column has to be displayed as two columns

can any help me


Sudhakar

matty
Posting Yak Master

161 Posts

Posted - 2009-04-25 : 01:45:23
SELECT PARSENAME(REPLACE(columnname, ':', '.'), 2) AS serverid,
PARSENAME(REPLACE(columnname, ':', '.'), 1) AS customerid
FROM TableName
Go to Top of Page

sudha12345
Starting Member

47 Posts

Posted - 2009-04-25 : 03:24:38
quote:
Originally posted by matty

SELECT PARSENAME(REPLACE(columnname, ':', '.'), 2) AS serverid,
PARSENAME(REPLACE(columnname, ':', '.'), 1) AS customerid
FROM TableName




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

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

is it possible to implement? if possible how can we implement this

please help me , its urgent


Sudhakar
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-25 : 03:35:19
quote:
Originally posted by sudha12345

quote:
Originally posted by matty

SELECT PARSENAME(REPLACE(columnname, ':', '.'), 2) AS serverid,
PARSENAME(REPLACE(columnname, ':', '.'), 1) AS customerid
FROM TableName




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

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

is it possible to implement? if possible how can we implement this

please help me , its urgent


Sudhakar


Do you want to compare the column value?
What is your 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:38:29
quote:
Originally posted by madhivanan

quote:
Originally posted by sudha12345

quote:
Originally posted by matty

SELECT PARSENAME(REPLACE(columnname, ':', '.'), 2) AS serverid,
PARSENAME(REPLACE(columnname, ':', '.'), 1) AS customerid
FROM TableName




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

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

is it possible to implement? if possible how can we implement this

please help me , its urgent


Sudhakar


Do you want to compare the column value?
What is your expected result?

Madhivanan

Failing to plan is Planning to fail




yes. we have compare the column value among the combination of server
and customer
i.e value beween p1 and i1
then value between p2 and i2
then value btween p3 and i3

and so on

note that serverid and cusomerid acts like a combination

Sudhakar
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-25 : 04:10:06
Do you want to display the difference after comparison?

Madhivanan

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

sudha12345
Starting Member

47 Posts

Posted - 2009-04-25 : 04:46:13
quote:
Originally posted by madhivanan

Do you want to display the difference after comparison?

Madhivanan

Failing to plan is Planning to fail




not that. that values will be displayed in the form chart in front end

if we display the difference alsi it is fine

Sudhakar
Go to Top of Page
   

- Advertisement -