barnettjacob
IS-IT--Management
Guys,
I've got a very simple Query that is part of a pick-list creator for customer orders. One of the fields I need to bring through is Warehouse location. This complicated matters as at present if there is more than one location for a product it effectively creates a double up of the order line!
In the code below, pw.location is my warehouse location - all I want to do is bring through the first available location.
Any help most appreciated.
Jacob
I've got a very simple Query that is part of a pick-list creator for customer orders. One of the fields I need to bring through is Warehouse location. This complicated matters as at present if there is more than one location for a product it effectively creates a double up of the order line!
In the code below, pw.location is my warehouse location - all I want to do is bring through the first available location.
Any help most appreciated.
Jacob
SQL:
select
convert(varchar(10),h.CreationDate,103) as 'Creation Date',
convert(varchar(10),h.insertionDate,103) as 'Insertion Date',
h.CustomerOrderNumber,
H.CustomerCode,
(case when H.DeliveryName is null then c.firstname + ' ' + c.Surname else h.DeliveryName end) as 'Name',
H.DeliveryAddress1,
H.DeliveryAddress2,
H.DeliveryAddress3,
H.DeliveryAddress4,
H.PostCode,
c.email,
d.productcode,
d.Quantity,
pw.locationcode
from eee..customerorderheader H
left join eee..customerorderdetail D on D.CustomerOrderNumber = H.CustomerOrderNumber
left join eee..customer C on C.customercode = H.customercode
left join eee..Product P on P.productcode = d.ProductCode
left join eee..productwarehouselocation pw on pw.productcode = d.productcode and pw.WarehouseBranchCode = '94'
where h.branchcode = '100' and h.CreationDate >='09/11/2012' and h.StatusT = 'Settled' and p.NonInventory = 0