• You need the ORDER BY, otherwise what TOP returns is unpredictable.

    You also need the reference to table trans in the subselect because the [order] table is filtered by a different set of trans rows than the main query.

    What indexes do you have on both tables? Can you post the actual execution plan?

    SELECT

    x.[Route],

    T1.[To license number. (/TO_LIC)] as TO_LIC,

    T1.[From license number.] AS FROM_LIC,

    T1.TO_ITEM,

    T1.FROM_LOCATION,

    T1.TO_LOCATION,

    T1.[Transaction type.] AS TransType,

    T1.[Populates by TRANS_NO_SEQ to generate a uniqu] as TransNo,

    T1.[ORD_NO] as OrderNO,

    T1.[Refers to ORD_KEY in ORD_MAST.] as ORD_KEY,

    T1.[References LOAD_ID in ORD_MAST.] as Load_ID_ORD_MAST,

    T1.[Date record was created.],

    CASE

    WHEN (T1.to_location like 'INN_MONO%BANE%' OR T1.to_location like 'INN_MONO_ORM%')

    THEN 'INFEED'

    WHEN (T1.to_location like 'INN_MONO%' OR T1.to_location like 'PRE_MONO_ORM%')

    THEN 'FLOOR'

    WHEN (T1.to_location like 'TROLLEY%')

    THEN 'TROLLEY'

    WHEN T1.to_location like 'STG%' OR T1.to_location like 'UT%GULV'

    THEN 'STAGED'

    WHEN (T1.to_location like 'UT_RC_AVSLAG%' OR T1.to_location like 'UT_OPPLAST%')

    THEN 'OUTFEED'

    ELSE 'UNKNOWN'

    END as Category

    FROM TRANS as T1

    CROSS APPLY (

    SELECT TOP 1

    [Route] = OM.ord_route

    FROM TRANS T

    INNER JOIN [ORDER] OM

    ON OM.ord_key = T.[Refers to ORD_KEY in ORD_MAST.]

    WHERE T.[From license number.] = T1.[From license number.]

    AND T.[Transaction type.] = 014

    AND (T.[Date record was created.] > T1.[Date record was created.]

    AND T.[Date record was created.] < T1.[Date record was created.] + 1)

    -- ORDER BY ...

    ) x

    WHERE T1.[From license number.] like '4%'

    and T1.[From license number.] not like '49%'

    and T1.to_item not like 'Z%'

    AND (

    T1.to_location like 'INN_MONO%'

    OR (T1.from_location like 'INN_MONO%' AND T1.to_location like 'INN_MONO%BANE%'

    OR (( T1.from_location like 'INN_MONO%BANE%' OR T1.from_location like 'INN_MONO_ORM%' OR T1.from_location like 'LOC_MG60001' AND T1.to_location like 'TROLLEY%')

    OR ( T1.from_location like 'TROLLEY%' AND ( T1.to_location like 'UT_OPPLAST&' OR T1.to_location like 'UT_RC_AVSLAG%')

    )

    OR ((T1.from_location like 'UT_OPPLAST%' OR T1.from_location like 'UT_RC_AVSLAG%' OR T1.from_location like 'INN_MONO%')

    AND (T1.to_location like 'STG%' OR T1.to_location like 'UT_OPPLAST%GULV' )

    )

    OR (T1.from_location like 'FULLRC_CO_EOL%' AND T1.to_location like 'INN_MONO_ORM%')

    OR (T1.from_location like 'PRE_MONO_ORM%' AND T1.to_location like 'INN_MONO_ORM%')

    ))

    )

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden