水晶报告中的命令级参数

时间:2014-10-10 10:30:22

标签: crystal-reports

我有一个包含2个纸箱和位置参数的报告。

如果我没有给出任何值,那么它应该给出所有值。

因此创建了2个命令级参数。只要我没有在参数中给出任何值,它就会显示所有值。

但即使我在纸箱或位置都给了一些价值,但仍显示所有价值。

请说明问题是什么

SELECT
      crt.carton_no, crtd.part_no, SUM(crtd.quantity) AS quantity,
      crtd.barcode, crtd.item_description
      , crt.put_away_location AS putAway
FROM
      carton crt, carton_details crtd
WHERE
      crt.carton_id = crtd.carton_id
      AND crt.status = 'N' AND
     ( crt.carton_no like  '{?cartonno}' or '{?cartonno}'  like '%' ) and (crt.put_away_location LIKE '{?location}' or '{?location}'  like '%')
GROUP BY
      crt.carton_no, crtd.carton_id, crtd.part_no
ORDER BY
      crt.put_away_location, crt.carton_no

1 个答案:

答案 0 :(得分:-1)

我猜你的查询总是忽略or条件...尝试使用Case

where
    CASE WHEN {?cartonno} Like ""
            THEN
                '{?cartonno}'  like '%'
            ELSE
                crt.carton_no like  '{?cartonno}'
            END

Note: I don't know which database you are using above is just an example of SQL... you can change it as required and use similarly for other parameter in where clause