Advertisement
Guest User

Untitled

a guest
Feb 18th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SCL 3.27 KB | None | 0 0
  1. SET TRANSACTION ISOLATION LEVEL read uncommitted
  2.  
  3. SET NOCOUNT ON
  4. --SELECT SUM (p) FROM
  5. --(
  6. Select
  7.  vw_ce_dms_transactions.TransactionDateTime,
  8.  vw_ce_dms_transactions.UID,
  9.  vw_ce_dms_transactions.Units,
  10.  vw_ce_dms_transactions.NetWeight,
  11.  oms_wo_header.WONo,
  12.  TraderDF.Text1,
  13.  vw_df_plu_file.PLUCode,
  14.  vw_df_plu_file.PLUDescription,
  15.  vw_df_plu_file.ChargeQty,
  16.  
  17.  CASE
  18.   When ce_oms_wo_lines.WOLineDFID Is NOT  Null THEN ce_oms_wo_lines.AValue1
  19.   ELSE vw_df_plu_file.UOM
  20.  End As UOM,
  21.  
  22.  ce_ims_items.NValue6 As Pieces,
  23.  ce_ims_items.AValue1 As ProdBatchNo
  24.  
  25.  
  26.  -----
  27.  ,ISNULL((
  28. CASE when
  29.     vw_df_plu_file.ChargeQty = 1 AND IsNull(CASE when ce_oms_wo_lines.WOLineDFID Is Null THEN vw_df_plu_file.UOM ELSE ce_oms_wo_lines.AValue1 End, 'Box')  = 'Box' THEN dbo.vw_ce_dms_transactions.Units
  30. when vw_df_plu_file.ChargeQty = 1 AND IsNull(CASE when ce_oms_wo_lines.WOLineDFID Is Null THEN vw_df_plu_file.UOM ELSE ce_oms_wo_lines.AValue1 End, 'Each')  = 'Each' THEN ce_ims_items.NValue6
  31. when vw_df_plu_file.ChargeQty = 1 AND IsNull(CASE when ce_oms_wo_lines.WOLineDFID Is Null THEN vw_df_plu_file.UOM ELSE ce_oms_wo_lines.AValue1 End, 'Unit')  = 'Unit' THEN ce_ims_items.NValue6
  32. ELSE dbo.vw_ce_dms_transactions.NetWeight END
  33. ),0)
  34.  
  35.  
  36. *
  37.  
  38. IsNull(CASE
  39.    --When ce_oms_wo_lines.WOLineDFID Is Null THEN IsNull(PL.Value,0 )
  40.    When ce_oms_wo_lines.WOLineDFID Is Null THEN IsNull([dbo].[fn_ce_GetCustomerProductPrice](Cust.Code + '|' + vw_df_plu_file.PLUCode , oms_wo_header.WOValidFromDate, 0), 0)
  41.    -- swapped FOR ticket 6919
  42.  
  43.  
  44.    ELSE oms_wo_lines.WOLinePrice
  45.   End,'0') AS Price
  46.  
  47.  -----
  48.  
  49. From vw_ce_dms_transactions
  50. Inner Join oms_order_header
  51.  On oms_order_header.OrderType = 'SO'
  52.  AND oms_order_header.OrderNo = vw_ce_dms_transactions.WONo
  53.  AND oms_order_header.OrderVersion = 0
  54. Inner Join oms_wo_header
  55.  On oms_wo_header.WOType = 'SO'
  56.  AND oms_wo_header.WONo = oms_order_header.OrderNo
  57.  AND oms_wo_header.WOVersion = 0
  58. Inner Join datafiles_data As TraderDF
  59.  On TraderDF.DatafileDataID = oms_order_header.TraderID
  60. Inner Join vw_df_plu_file
  61.  On vw_ce_dms_transactions.PLUID = vw_df_plu_file.PLUID
  62. Inner Join ce_ims_items
  63.  On ce_ims_items.ItemTypeCode = 'BOX'
  64.  AND ce_ims_items.ItemID = vw_ce_dms_transactions.UID
  65. Left join ce_oms_wo_lines
  66.  On ce_oms_wo_lines.WOType = 'SO'
  67.  AND ce_oms_wo_lines.WONo = vw_ce_dms_transactions.WONo
  68.  AND ce_oms_wo_lines.WOVersion = 0
  69.  AND ce_oms_wo_lines.WOLineNo = vw_ce_dms_transactions.WOLineNo
  70.  AND ce_oms_wo_lines.WOLineDFID = vw_ce_dms_transactions.PLUID
  71. Left join oms_wo_lines
  72.  On oms_wo_lines.WOType = 'SO'
  73.  AND oms_wo_lines.WONo = vw_ce_dms_transactions.WONo
  74.  AND oms_wo_lines.WOVersion = 0
  75.  AND oms_wo_lines.WOLineNo = vw_ce_dms_transactions.WOLineNo
  76.  AND oms_wo_lines.WOLineDFID = vw_ce_dms_transactions.PLUID
  77. ---
  78. Inner Join datafiles_data As Cust
  79.    On Cust.DatafileDataID = oms_order_header.TraderID
  80.  
  81. --Left Join kp_settlement_price_tracker As PL
  82. --  On PriceTypeCode = 'CUSTOMER_PRODUCT_PRICE'
  83. --  AND [Key] LIKE Cust.Code + '|' + vw_df_plu_file.PLUCode
  84. --  AND ValidFromDatetime <= oms_wo_header.WOValidFromDate
  85. --      removed FOR ticket 6919
  86.  
  87. Where
  88.  TransactionType = 'PALLET_DISPATCH_PICKING'
  89.  AND (TransactionDateTime between '20150117' AND '20150218 23:59:59')
  90.  AND Cancelled = 0
  91. Order BY DMSTransactionID desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement