use [test1_AlplaPROD2.0_Read]

select 
customerartno as CustomerArticleNumber
,h.CustomerOrderNumber as CustomerOrderNumber
,l.CustomerLineItemNumber as CustomerLineNumber
,r.CustomerReleaseNumber as CustomerRealeaseNumber
,r.Quantity
,format(r.DeliveryDate, 'MM/dd/yyyy HH:mm') as DeliveryDate
,h.CustomerHumanReadableId as CustomerID
,r.Remark
--,* 
from [order].[Release] as r (nolock)

left join
[order].LineItem as l (nolock) on
l.id = r.LineItemId

left join
[order].Header as h (nolock) on
h.id = l.HeaderId

WHERE releaseState not in (1, 2, 3, 4)
AND h.CreatedByEdi = 1
AND r.deliveryDate < getdate() + 1
--AND h.CustomerHumanReadableId in (0)


order by r.deliveryDate