Advertisement
Pandaaaa906

Untitled

Dec 30th, 2022
1,657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.30 KB | None | 0 0
  1. SELECT
  2.     [Vendor].[cVenName] AS supplier_name,
  3.     SUBSTRING ( [PO_Podetails].[cInvCode], 3, len( [PO_Podetails].[cInvCode] ) ) AS cat_no,
  4.     [PO_Podetails].[cFree1] AS package,
  5.     [PO_Podetails].[iQuantity] AS quantity,
  6.     [PO_Podetails].[iSum] AS price,
  7.     CAST ( datediff( ww, [PO_Pomain].[cAuditDate], [PO_Podetails].[dArriveDate] ) AS NVARCHAR ( MAX ) ) + '周' AS delivery,
  8.     [PO_Pomain].[cPOID] + ( '+' + COALESCE ( [PO_Podetails].[cbMemo], '' ) ) AS remark,
  9. CASE
  10.        
  11.         WHEN ( [PO_Pomain_extradefine].chdefine2 LIKE '%增值%' ) THEN
  12.         1 ELSE 0
  13.     END AS with_vat,
  14.     [PO_Pomain].[cAuditDate] AS created_at, '采购订单' AS source_type, 'RMB' AS currency,
  15.     [PO_Podetails].[ID] AS source_id,
  16.     [UA_User].[cUser_Name] AS created_by
  17. FROM
  18.     [PO_Podetails]
  19.     JOIN [PO_Pomain] ON [PO_Pomain].[POID] = [PO_Podetails].[POID]
  20.     JOIN [Vendor] ON [Vendor].[cVenCode] = [PO_Pomain].[cVenCode]
  21.     JOIN [Inventory] ON [Inventory].[cInvCode] = [PO_Podetails].[cInvCode]
  22.     JOIN [PO_Pomain_extradefine] ON [PO_Pomain].[POID] = [PO_Pomain_extradefine].[POID]
  23.     JOIN [UA_User] ON [UA_User].[cUser_Id] = [PO_Pomain].[cPersonCode]
  24. WHERE
  25.     [PO_Pomain].[cAuditDate] IS NOT NULL
  26.     AND [Inventory].[cInvCCode] NOT LIKE '07%'
  27.     AND ( [PO_Podetails].freceivedqty > 0 OR [PO_Podetails].[iInvQTY] > 0 )
  28.     AND [PO_Podetails].dArriveDate > '2022-09-20'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement