我创建了一份报告,但我已经停止了对您来说可能非常简单的障碍,但我无法考虑任何能让我解决问题的方法。
我创建了一个基于SQL查询(带有多个CTE)的报告,应该通过以下方式进行参数化:
where
deliverydate between @FromDate and @ToDate
and
carrierid = @Carrier
到目前为止它还在运作。但我想创建另一个具有3个值的参数。根据这些值,我想获得符合条件的所有记录。像那样排序:
Column1和column2是我创建的报告中的列。 最终的选择看起来像这样:
SELECT SALESID ,
CARRIERID ,
dlvmodeid ,
SUM(totalweight) AS totalweight ,
SUM(totalcharges) AS totalcharges ,
TOTALCHARGESCURRENCY ,
SUM(HowManyPackagesForThisSO) AS HowManyPackagesForThisSO ,
SUM(HowManyPackagesForThisSO_st) AS HowManyPackagesForThisSO_st ,
SUM(InHowManyDays) AS InHowManyDays ,
SUM(cspjnumber) AS HowManyPackingSlip
FROM countingcte
WHERE deliverydate BETWEEN @FromDate AND @ToDate
AND carrierid = @Carrier
GROUP BY SALESID ,
CARRIERID ,
dlvmodeid ,
TOTALCHARGESCURRENCY
有没有人知道我的问题的解决方案?
我想到的确切列是HowManyPackagesForThisSO和HowManyPackagesForThisSO_st。
答案 0 :(得分:3)
将此添加到您的WHERE
子句:
AND ((@Param = 1) OR
(@Param = 2 AND col1 <> col2) OR
(@Param = 3 AND col1 = col2))