Jump to content

Sql Pin Koncham Help Kavali Urgent... To My Friend


Recommended Posts

Posted

[quote name='saritha24' timestamp='1342766474' post='1302166352']
CREATE TABLE T1 (ItemNumber bigint, Itemdesc varchar(100))
INSERT INTO T1 VALUES (1010100001, '63.5 x 76.0 x 300 GSM ITC CFBB')
CREATE TABLE T2 (ItemNumber bigint, segmentcode varchar(10), segmentdesc varchar(100), segmentvalue varchar(100))
INSERT INTO T2 VALUES (1010100001, 'UD1','Class Level1','Paper&Board')
INSERT INTO T2 VALUES (1010100001, 'UD2','Class Level2','CFBB')
INSERT INTO T2 VALUES (1010100001, 'UD3','Class Level3','ITC CFBB')
INSERT INTO T2 VALUES (1010100001, 'UD4','Class Level4','DIRECT')
INSERT INTO T2 VALUES (1010100001, 'UD5','Class Level5',NULL)
INSERT INTO T2 VALUES (1010100001, 'UD6','GSM','300')
INSERT INTO T2 VALUES (1010100001, 'UD7','SIZE','63.5 x 76.0')
INSERT INTO T2 VALUES (1010100001, 'UD8','Manufacturer','IT LIMITED-BHADRACHALAM')


SELECT A.ItemNumber, A.ItemDesc, B.ud1, B.ud2, B.ud3 , B.ud4, B.ud5, B.ud6, B.ud7, B.ud8
FROM T1 AS A JOIN (
SELECT itemnumber, [ud1],[ud2],[ud3],[ud4],[ud5],[ud6],[ud7],[ud8]
FROM ( SELECT itemnumber, [segmentcode], segmentvalue
from T2
) P PIVOT ( MAX(segmentvalue) for [segmentcode] IN ([ud1],[ud2],[ud3],[ud4],[ud5],[ud6],[ud7],[ud8])
) AS Pvt
) B ON A.ItemNumber = B.ItemNumber



Try replacing T1, T2 with your table names. Good Luck!!
[/quote]

hi saritha garu.. i will try and let u knoe

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • kakatiya

    15

  • karna11

    3

  • saritha24

    3

  • JUJUBI_JULABI

    2

Top Posters In This Topic

Posted

thanks all.. and saritha garu as welll

she tried out herself :D

thanks all for your help

×
×
  • Create New...