Třídová akce

Kód:
22
Tělo:
#ORA
Select
  *
From
  ( 
#ALL
Select
#IB
  First :MaxRowsCount
#MS
TOP (:MaxRowsCount)
#ALL
  /* Stejné StoreCard_ID, QUnit, UnitRate, StoreBatch_ID, pokud ne přičteme 1 do skóre */
  Case (
    Select
      count(*)
    From
      LogStoreContentsForStrat_VIEW IC
    Where
      IC.ID = LSC.ID and
      IC.StoreCard_ID = :StoreCard_ID and
      (
        (
          IC.StoreBatch_ID is null and
          :SBatch_ID_NULL = 'A'
        ) or
        (IC.StoreBatch_ID = :StoreBatch_ID)
      ) and
      IC.QUnit = :QUnit and
      (
        ((:UnitRate - IC.UnitRate) < 0.0005) and
        ((IC.UnitRate - :UnitRate) < 0.0005)
      )
  ) when 0 then 0 else 1 end
  +
  /* Stejné StoreCard_ID, QUnit, UnitRate, StoreBatch_ID a Quantity, pokud ne přičteme 1 do score*/
  Case (
    Select
      count(*)
    From
      LogStoreContentsForStrat_VIEW IC
    Where
      IC.ID = LSC.ID and
      IC.StoreCard_ID = :StoreCard_ID and
      (
        (
          IC.StoreBatch_ID is null and
          :SBatch_ID_NULL = 'A'
        ) or
        (IC.StoreBatch_ID = :StoreBatch_ID)
      ) and
      IC.QUnit = :QUnit and
      (
        ((:UnitRate - IC.UnitRate) < 0.0005) and
        ((IC.UnitRate - :UnitRate) < 0.0005)
      ) and
      (
        ((:Quantity - IC.Quantity) < 0.0000005) 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, Quantity Desc, Position_Accessibility
#ORA
  )
where
  RowNum <= :MaxRowsCount

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