Třídová akce

Kód:
25
Tělo:
#ORA
Select
  *
From
  (
#ALL
Select
#MS
  TOP (:MaxRowsCount)  
#IB
  First :MaxRowsCount
#ALL
  /* Dostatečné Quantity v libovolné jednotce, pokud ano, přičteme 1 do skóre */
  Case (
    Select
      count(*)
    From
      LogStoreContentsForStrat_VIEW IC
    Where
      (IC.ID = LSC.ID) and
      ((IC.Quantity - :Quantity) > -0.0000005)      
  ) when 0 then 0 else 1 end
  +
  /* Dostatečné Quantity ve stejné jednotce, pokud ano, přičteme 1 do skóre */
  Case (
    Select
      count(*)
    From
      LogStoreContentsForStrat_VIEW IC
    Where
      (IC.ID = LSC.ID) and
      (IC.QUnit = :QUnit) and
      (
        ((:UnitRate - IC.UnitRate) < 0.0005) and
        ((IC.UnitRate - :UnitRate) < 0.0005)
      ) and
      ((IC.Quantity - :Quantity) > -0.0000005)
  ) when 0 then 0 else 1 end Score,
  ID,
  Position_ID,
  Position_Code,
  Position_Accessibility,
  Position_Frozen,
  Quantity,
  QUnit,
  UnitRate,
  IndivisibleQuantity,
  CompareStorageDate$DATE,
  StoreBatch_Name,
  PositionType
from
#ORA
  Table
    (
    Cast
      (      
      LogstoreCustOutputStrat(
        :StoreCard_ID,
        :Store_ID,
        :StoreBatch_ID,
        :SBATCH_ID_NULL,
        :Quantity,
        :AccessibilityLimit,
        :IsAccessibilityLimitFilter,
        'A',
        :RespectIndivisibleQuantity)        
        as LogStoreCustOutputStrat_Table  
      )
    ) LSC
#IB
      LogstoreCustOutputStrat(
        :StoreCard_ID,
        :Store_ID,
        :StoreBatch_ID,
        :SBATCH_ID_NULL,
        :Quantity,
        :AccessibilityLimit,
        :IsAccessibilityLimitFilter,
        'A',
        :RespectIndivisibleQuantity) LSC
#MS
      LogstoreCustOutputStrat(
        :StoreCard_ID,
        :Store_ID,
        :StoreBatch_ID,
        :SBATCH_ID_NULL,
        :Quantity,
        :AccessibilityLimit,
        :IsAccessibilityLimitFilter,
        'A',
        :RespectIndivisibleQuantity) LSC          
#ALL
order by
  Position_Frozen Desc,
  1 Desc,  
  (Case (Select count(*) From LogStoreContentsForStrat_VIEW IC Where (IC.ID = LSC.ID) and ((IC.Quantity - :Quantity) > -0.0000005)) when 0 then Quantity else 0 end) Desc, 
  Position_Accessibility, 
  Quantity Desc
#ORA
  )
where
  RowNum <= :MaxRowsCount

Generated by ABRA Software a.s. 27.10.2021 16:35:19