正如标题所说,我已经构建了一个Crystal Report来从SQL服务器中提取数据。 Crystal Reports生成的SQL查询在复制到SSMS时会按预期提取数据,但在从Crystal Reports运行报表时不会提取任何记录。
我的记录选择:
({PRECEIPTD.CREDAT_0} >= {?startDate} AND {PRECEIPTD.CREDAT_0} <= {?endDate})
AND ISNULL({PINVOICED.NUM_0})
AND IF ISNULL({?bpr}) OR {?bpr} = "" THEN {PORDERQ.BPSNUM_0} = {PORDERQ.BPSNUM_0} ELSE {PORDERQ.BPSNUM_0} = {?bpr}
我也试过写这样的选择,它会拉出所有相同的记录:
({PRECEIPTD.CREDAT_0} >= {?startDate} AND {PRECEIPTD.CREDAT_0} <= {?endDate})
AND ISNULL({PINVOICED.NUM_0})
AND IF ISNULL({?bpr}) OR {?bpr} = "" THEN {PORDERQ.BPSNUM_0} LIKE "*" ELSE {PORDERQ.BPSNUM_0} = {?bpr}
我正在使用Crystal Reports 2013 SP11,通过ODBC连接访问数据库。
编辑: Crystal查询Crystal生成:
SELECT
PRECEIPTD.CREDAT_0
, PORDERQ.BPSNUM_0
, PORDERQ.POHNUM_0
, PORDERQ.ITMREF_0
, PORDERQ.QTYPUU_0
, PORDERP.NETPRI_0
, PRECEIPTD.PTHNUM_0
, PINVOICED.NUM_0
FROM ((x3v6.PROD.PORDERQ PORDERQ
INNER JOIN x3v6.PROD.PORDERP PORDERP ON
(PORDERQ.POHNUM_0=PORDERP.POHNUM_0)
AND (PORDERQ.POPLIN_0=PORDERP.POPLIN_0))
LEFT OUTER JOIN x3v6.PROD.PRECEIPTD PRECEIPTD ON
((PORDERQ.POPLIN_0=PRECEIPTD.POPLIN_0)
AND (PORDERQ.POQSEQ_0=PRECEIPTD.POQSEQ_0))
AND (PORDERQ.POHNUM_0=PRECEIPTD.POHNUM_0))
LEFT OUTER JOIN x3v6.PROD.PINVOICED PINVOICED ON
(PRECEIPTD.PTHNUM_0=PINVOICED.PTHNUM_0)
AND (PRECEIPTD.PTDLIN_0=PINVOICED.PTDLIN_0)
WHERE
(PRECEIPTD.CREDAT_0>={ts '2018-01-01 00:00:00'} AND PRECEIPTD.CREDAT_0<{ts '2019-01-01 00:00:00'})
AND PINVOICED.NUM_0 IS NULL
AND PORDERQ.BPSNUM_0=PORDERQ.BPSNUM_0
ORDER BY
PORDERQ.BPSNUM_0
, PRECEIPTD.CREDAT_0
答案 0 :(得分:0)
进行了一些搜索,并在https://stackoverflow.com/a/43203088/8672275找到了类似的帖子。我的记录选择中的AND ISNULL({PINVOICED.NUM_0})
部分正在关闭Crystal Reports。我将其更改为AND ToText({PINVOICED.NUM_0}) = ""
,报告正在返回我期望看到的内容。