Please, help me to understand what person tried to see when s/he wrote subquery:
(SELECT TOP 1 ''X''
FROM ORDER_DETAIL OD (NOLOCK)
WHERE
OD.MASTER_CUSTOMER_ID = ORDER_DETAIL.MASTER_CUSTOMER_ID
AND OD.PRODUCT_ID = ORDER_DETAIL.PRODUCT_ID
AND DATEDIFF(DAY,OD.ORDER_DATE, ORDER_DETAIL.ORDER_DATE) BETWEEN 1 AND 180)
I can't seem to understand WHY would you create this OD alias and still have ORDER_DETAIL name and join within table and all of it is part of SP.
Is there known situations when you have to go this way?
Please, sort it out for me if you would,
THANKS
I finally got it all together and forgot where I put it.
(SELECT TOP 1 ''X''
FROM ORDER_DETAIL OD (NOLOCK)
WHERE
OD.MASTER_CUSTOMER_ID = ORDER_DETAIL.MASTER_CUSTOMER_ID
AND OD.PRODUCT_ID = ORDER_DETAIL.PRODUCT_ID
AND DATEDIFF(DAY,OD.ORDER_DATE, ORDER_DETAIL.ORDER_DATE) BETWEEN 1 AND 180)
I can't seem to understand WHY would you create this OD alias and still have ORDER_DETAIL name and join within table and all of it is part of SP.
Is there known situations when you have to go this way?
Please, sort it out for me if you would,
THANKS
I finally got it all together and forgot where I put it.