跳至主要內容

采购订单报表(多条件模糊查询)

五六零网校小于 1 分钟

代码示例

SELECT T0.[DocNum], T0.[taxDate], T0.[CardCode], T0.[CardName], T1.[ItemCode]
	, T1.[Dscription], T4.[SlpName] AS '采购员', T1.[UseBaseUn]
	, T1.[Quantity], T1.[Price], T1.[VatPrcnt], T1.[DiscPrcnt], T1.[LineTotal]
	, T1.[Quantity] - T1.[OpenQty] AS '收货数量',  T1.[WhsCode], T1.[OpenQty]
	, T2.[OnHand], T0.[Comments]
FROM [dbo].[OPOR] T0
	INNER JOIN [dbo].[POR1] T1 ON T0.[DocEntry] = T1.[DocEntry]
	INNER JOIN [dbo].[OITM] T2 ON T1.[ItemCode] = T2.[ItemCode]
	INNER JOIN [dbo].[OITB] T3 ON T2.[ItmsGrpCod] = T3.[ItmsGrpCod]
	INNER JOIN [dbo].[OSLP] T4 ON T0.[SlpCode] = T4.[SlpCode]

WHERE (T1.[ItemCode] LIKE '%%[%0]%%'
		OR '[%0]' = '')
	AND (T0.[taxDate] LIKE '%%[%4]%%'
		OR '[%4]' = '')
	AND (T0.[DocStatus] LIKE '%%[%5]%%'
		OR '[%5]' = '')
	AND (T3.[ItmsGrpNam] LIKE '%%[%6]%%'
		OR '[%6]' = '')
	AND (T4.[slpname] LIKE '%%[%7]%%'
		OR '[%7]' = '')
	AND (T0.[CARDCODE] LIKE '%%[%8]%%'
		OR '[%8]' = '')
	AND (T0.[Cardname] LIKE '%%[%9]%%'
		OR '[%9]' = '')
	AND (T0.[DOCNUM] LIKE '%%[%10]%%'
		OR '[%10]' = '')
	AND T0.[CANCELED] = 'N'