我正在尝试从2个表OINV和INV1中提取发票数据。我需要查询才能给出指定日期范围的结果。这是我的疑问:
SELECT T0."DocDate", T0."NumAtCard", T0."CardName", T1."ItemCode", T1."Quantity", T1."Price", T0."DocTotal"
FROM "OINV" T0 LEFT JOIN
INV1 T1
ON T0."DocEntry" = T1."DocEntry"
WHERE T0."CANCELED" = 'N', T0."DocDate" >=[%0] AND T0."DocDate" <=[%1]
当我执行日期输入并且不返回任何内容时,它不会要求输入日期。当我单独使用OINV表时,日期输入工作正常,但在我进行连接时没有。任何想法为什么会发生这种情况?
答案 0 :(得分:0)
查询:
SELECT T0."DocDate", T0."NumAtCard", T0."CardName", T1."ItemCode", T1."Quantity", T1."Price", T0."DocTotal"
FROM "OINV" T0 LEFT JOIN
INV1 T1
ON T0."DocEntry" = T1."DocEntry"
WHERE T0."CANCELED" = 'N' AND T0."DocDate" >=[%0] AND T0."DocDate" <=[%1]
在我的系统上正常工作
删除","
并添加"AND"
答案 1 :(得分:0)
删除所有列中的“”。
SELECT T0.DocDate, T0.NumAtCard, T0.CardName, T1.ItemCode, T1.Quantity, T1.Price, T0.DocTotal
FROM OINV T0 LEFT JOIN
INV1 T1
ON T0.DocEntry = T1.DocEntry
WHERE T0.CANCELED = 'N' AND T0.DocDate >=[%0] AND T0.DocDate <=[%1]
答案 2 :(得分:0)
在你的代码之前添加这个
/*SELECT * FROM OINV T0*/
declare @FromDate date
declare @ToDate date
/* WHERE */
set @FromDate = /* T0.DocDate */‘[%0]’
set @ToDate =/* T0.DocDate */ ‘[%1]’