Wednesday, August 6, 2008

Cust History

declare @custnmbr as varchar(22)

set @custnmbr = 'CUSTOMER-ID'

select CUSTNMBR, DOCDATE as TrnDate,
case SOPTYPE
when 1 then 'Quote'
when 2 then 'Order'
when 3 then 'Invoice'
when 4 then 'Return'
when 5 then 'Backorder'
when 6 then 'Fulfillment'
end as Document,
SOPNUMBE as DocumentNo
from SOP30200
where CUSTNMBR = @custnmbr
and VOIDSTTS = 0
order by DOCDATE

No comments: