根据ssrs

时间:2018-04-10 15:17:16

标签: sql reporting-services ssrs-2008

在下面的表格中,根据订单数量应选择的最长提前期,订单数量不应为零。如果为零则表示需要根据提前期的下一个最高值选择下一个值。

在这个例子中,In提前期最大值为12.根据提前期顺序qty为0,所以下一个最高提前期是11,最终答案选择为5。

目前我正在使用此代码。它首先出现了价值。需要应用上述逻辑。

=LookupSet(Fields!InvoiceNumber.Value & Fields!PONumber.Value, Fields!InvoiceNumber.Value & Fields!PONumber.Value,Fields!CustomerOrderQty.Value, "dsILI")(0)

我的查询。

SELECT mmm_mmmidno, mmm_productdesc, mmm_invoiceno AS InvoiceNumber, mmm_pono AS PONumber, mmm_billunit AS BillUnit,mmm_customerorderedqty AS CustomerOrderQty,mmm_itemleadtime as ItemLeadTime FROM Filteredmmm_invoicelineiteminfo

数据:

   Invoice No   Lead Time   Order Qty
   -----------------------------------
   ET2010           2         10
   ET2010           5         22
   ET2010           8          4
   ET2010           4          7
   ET2010           6          8
   ET2010          12          0
   ET2010          11          5
   ET2010           9          3

1 个答案:

答案 0 :(得分:0)

只需更改您的查询:

SELECT mmm_mmmidno
      ,mmm_productdesc
      ,mmm_invoiceno AS InvoiceNumber
      ,mmm_pono AS PONumber
      ,mmm_billunit AS BillUnit
      ,mmm_customerorderedqty AS CustomerOrderQty
      ,mmm_itemleadtime as ItemLeadTime 
FROM Filteredmmm_invoicelineiteminfo
WHERE mmm_customerorderedqty > 0
ORDER BY ItemLeadTime DESC