Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Query self relating table

$
0
0

I have a self relating table that I need to query in the following way.

Table

ID,
ParentId,
Format,
Qty

sample records

1, Null, A4, 4
2,1, B/W,  4
3,1, Duplex, 2

4,Null, A3, 1
5,4, Color, 1

somehow I need to get something like this

ID, Format1, Qty1, Format2, Qty2,Format3, Qty3 Etc....

1, A4,4,B/W,4,Duplex,2

4, A3,1,Color,1, Null, Null

Is this possible ?

BTW the table has a maximum of 4 self relations


Viewing all articles
Browse latest Browse all 23857

Trending Articles