January 31, 2013 at 4:22 am
I am Ramanathan and working in SQL SERVER 2008….Please help me
Table1
Location--Field
A1
A2
A3
B1
B2
B3
How to change an below format from table1
AB--Field
A1B1
A2B2
A3B3
January 31, 2013 at 4:43 am
declare @tab table (col1 char(2))
insert into @tab values
('A1'),
('A2'),
('A3'),
('B1'),
('B2'),
('B3')
SELECT
A.Col1,
B.Col1
FROM
(
SELECT
ROW_NUMBER() OVER(PARTITION BY LEFT(Col1,1) ORDER BY Col1) AS RowNum,
Col1
FROM
WHERE
LEFT(Col1,1) = 'A'
) AS A
FULL OUTER JOIN
(
SELECT
ROW_NUMBER() OVER(PARTITION BY LEFT(Col1,1) ORDER BY Col1) AS RowNum,
Col1
FROM
WHERE
LEFT(Col1,1) = 'B'
) AS B
ON
A.RowNum = B.RowNum
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy