1800radiatoranalytics of 1-800 Radiator-SQL Codes
6/23/2017 - 3:57 PM

This query allows you to quickly view all of the sales orders and associated purchase orders created for/through the virtual warehouse proje

This query allows you to quickly view all of the sales orders and associated purchase orders created for/through the virtual warehouse project (lamps).

--Modify this parameter value to meet your needs. 
DECLARE @StartDate DATETIME = '2017-06-01' 

--SELECT @StartDate = cast(cast(getdate() as date) as datetime)-14 
SELECT w.companyid, 
       w.warehouseid, 
       a.somcompanyname                     [Company], 
       a.somso                              [SO], 
       a.somtotal, 
       a.somdefaultwhse                     [CreditWhse], 
       a.whsenumber                         [ShippingWhse], 
       Cast(a.somdatetime AS SMALLDATETIME) [SO Date], 
       c.soditem                            [Item], 
       d.poid                               [PO], 
       a.somsalesman                        [Salesman] 
--,d.PoId  
--, pd.PODDesc 
FROM   gxwizmo_10.dbo.gxsom a (nolock) 
       JOIN gxwizmo_24.dbo.virtualprovider b (nolock) 
         ON a.whsenumber = b.virtualwarehouse 
            AND b.virtualwarehouse > 899 
       --old VWs were in the 400-500 range, but all automated VWs are 900+ 
       JOIN gxwizmo_10..warehouse w 
         ON w.warehouseid = a.somdefaultwhse 
       LEFT JOIN gxwizmo_24.dbo.vwlogitem c 
              ON a.somso = c.somso 
       LEFT JOIN gxwizmo_24.dbo.vwpom d (nolock) 
              ON d.vwpomid = vwlogid 
WHERE  a.somdatetime > @StartDate 
--and a.somso =  
--and a.SOMSalesman = 'ECMCCC' 
ORDER  BY a.somdatetime DESC 
--select top 10 * 
--from gxwizmo_10.dbo.GXSOM 
--where SOMSalesman = 'ECMCCC' 
--and SOMDate > '2016-08-01' 
--select * from gxWizmo_24..vwPom 
--where vwPomId in (1889, 1897)