첨부파일처럼
좌측테이블을 우측테이블처럼 보이게 하고싶습니다..
어떻게해야하는지 판단이 안서고, 어떻게 조회해야되는지도모르겠어서요.
질문드립니다.
Comment 3
-
초짜해커
2014.06.03 15:19
DECLARE @DATA TABLE (COLA VARCHAR(10), COLB INT)INSERT @DATA SELECT '489227', 1INSERT @DATA SELECT '489227', 2INSERT @DATA SELECT '489227', 3INSERT @DATA SELECT '489227', 4INSERT @DATA SELECT '489227', 5INSERT @DATA SELECT '489227', 6INSERT @DATA SELECT '489227', 7INSERT @DATA SELECT '489227', 8INSERT @DATA SELECT '489227', 9INSERT @DATA SELECT '489227', 10INSERT @DATA SELECT '489227', 11INSERT @DATA SELECT '489227', 12SELECT COLA, COLB = (SELECT '' + COLB FROM @DATA WHERE COLA = A.COLA FOR XML PATH (''))FROM @DATA AGROUP BY COLA -
스타카토
2014.06.03 16:03
감사합니다.
-
한태
2016.03.25 18:47
CREATE TABLE FRI
(COLA VARCHAR(10), COLB INT)
INSERT INTO FRI VALUES('489227', 1)
INSERT INTO FRI VALUES('489227', 2)
INSERT INTO FRI VALUES('489227', 3)
INSERT INTO FRI VALUES('489227', 4)
INSERT INTO FRI VALUES('489227', 5)
INSERT INTO FRI VALUES('489227', 6)
INSERT INTO FRI VALUES('489227', 7)
INSERT INTO FRI VALUES('489227', 8)
INSERT INTO FRI VALUES('489227', 9)
INSERT INTO FRI VALUES('489227', 10)
INSERT INTO FRI VALUES('489227', 11)
INSERT INTO FRI VALUES('489227', 12)
SELECT * FROM FRI
DECLARE @sql_command varchar(max);
SET @sql_command = '';
SELECT @sql_command += convert(varchar,COLB) FROM FRI
SELECT TOP 1 COLA, @sql_command AS COLB
FROM FRI