SELECT A.ord_no, A.cmt, B.cmt, C.cmt
FROM Yourtable A
LEFT JOIN Yourtable B ON A.ord_no = B.ord_no AND B.cmt LIKE 'Tracking%'
LEFT JOIN Yourtable C ON A.ord_no = C.ord_no AND C.cmt LIKE 'Ground%'
WHERE A.cmt LIKE 'Shipped%';
You could then use STUFF or SUBSTRING to get the part of cmt you want.
I went the cmt_seq_no route and that seems to be working.
SELECT real_ord_no, ltrim([1]) AS ShipDate, [2] AS Tracking, ltrim([3]) AS Service,
[4] AS Weight, [5] AS Packages, [6] as Billing
FROM
(SELECT real_ord_no, cmt_seq_no, cmt
FROM oecmthst_sql
where line_seq_no = 0 and (LEFT(ltrim(cmt),11)='Shipped on:' or LEFT(ltrim(cmt),10)='Tracking#:' or
LEFT(ltrim(cmt),8)='Service:' or LEFT(ltrim(cmt),13)='Total Weight:' or
LEFT(ltrim(cmt),19)='Number of Packages:' or LEFT(ltrim(cmt),15)='Billing Option:')) p
PIVOT
(
max(cmt)
FOR cmt_seq_no IN
( [1], [2], [3], [4], [5], [6] )
) AS pvt
I would go that route if: there are relatively few JOINs, and in particular if there are "several" columns to be included from, eg., a parent table as I think that makes PIVOT unwieldy (in this case only [real_ord_no] being displayed)