Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 水晶报告2008。在查询中使用自定义函数或公式_Function_Group By_Crystal Reports - Fatal编程技术网

Function 水晶报告2008。在查询中使用自定义函数或公式

Function 水晶报告2008。在查询中使用自定义函数或公式,function,group-by,crystal-reports,Function,Group By,Crystal Reports,我需要编写一个查询来计算匹配给定条件的字段值之和。因此,我编写了这个自定义报告函数 函数get_order_amount order_amount作为数字,inv_date作为日期,month作为字符串,year作为字符串 - ... 如果inv_dateyyyymm我认为您不能将自定义函数与SQL查询混合使用 相反,您可以直接在SQL中使用CASE语句 案例陈述应该是这样的 Select EXTRACT(YEAR FROM ORDER_DATE) as YEAR ,

我需要编写一个查询来计算匹配给定条件的字段值之和。因此,我编写了这个自定义报告函数

函数get_order_amount order_amount作为数字,inv_date作为日期,month作为字符串,year作为字符串 - ...
如果inv_dateyyyymm我认为您不能将自定义函数与SQL查询混合使用

相反,您可以直接在SQL中使用CASE语句

案例陈述应该是这样的

Select EXTRACT(YEAR FROM ORDER_DATE) as YEAR
              , SUM(CASE
              WHEN INV_DATE <= **SOMEDATE** THEN
                        ORD_AMOUNT
              ELSE
                        0
              END) as Custom_Total
    FROM ORDERS
GROUP BY EXTRACT(YEAR FROM ORDER_DATE)

您正在尝试将sql查询与crystal reports功能混合使用…我不确定它是如何工作的,但不是在查询中使用。。。不要使问题复杂化。。在crystal报表公式中使用简单的select语句和自定义函数