Hi there,
I have a record set
SELECT testingInfo1.xColumn, testingInfo2.tColumn
FROM testing1 testingInfo1
INNER JOIN testing2 testingInfo2
ON testingInfo1.column1 = testingInfo2.fColumn
xColumn tColumn
x1 t1
x1 t2
x1 t3
x2 t2
x3 t1
x3 t2
x4 t1
I would like to display
xColumn t1 t2 t3 t4 t5 ....
x1 1 1 1 0 0
x2 0 1 0 0 0
x3 1 1 0 0 0
etc
I could possibly do that using temp and cursors etc but any good
solutions to share?
Thanks,
Toby
yootaeho@.gmail.com wrote:
> Hi there,
> I have a record set
> SELECT testingInfo1.xColumn, testingInfo2.tColumn
> FROM testing1 testingInfo1
> INNER JOIN testing2 testingInfo2
> ON testingInfo1.column1 = testingInfo2.fColumn
> xColumn tColumn
> x1 t1
> x1 t2
> x1 t3
> x2 t2
> x3 t1
> x3 t2
> x4 t1
> I would like to display
> xColumn t1 t2 t3 t4 t5 ....
> x1 1 1 1 0 0
> x2 0 1 0 0 0
> x3 1 1 0 0 0
> etc
> I could possibly do that using temp and cursors etc but any good
> solutions to share?
> Thanks,
> Toby
see PIVOT and UNPIVOT in BOL
Monday, March 19, 2012
getting records horizontally
Labels:
database,
horizontally,
microsoft,
mysql,
oracle,
record,
records,
server,
setselect,
sql,
tcolumnfrom,
testing1,
testing2,
testinginfo1,
testinginfo1inner,
testinginfo2,
testinginfo2on,
xcolumn
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment