私は次の表を持っています
QuotationId QuotationDetailId DriverId RangeFrom RangeTo FixedAmount UnitAmount
-------------------------------------------------------------------------------------------
10579 7 1 1 1 1154.00 0.00
10579 7 2 2 2 1731.00 0.00
10579 11 1 0 10 0.00 88.53
10579 11 2 11 24 885.30 100.50
10579 11 3 25 34 2292.30 88.53
次のロジックを使用して、SQL Server でクエリを作成する必要があります。
- グループ化は QuotationId + QuotationDetailId です。
このブロックごとに、2 行目から前の行の値を合計する必要があります。
Amount + UnitAmount * RangeFrom + FixedAmount of the current row
したがって、この場合、結果の出力は次のようになります。
QuotationId QuotationDetailId DriverId RangeFrom RangeTo FixedAmount UnitAmount
10579 7 1 1 1 1154.00 0.00
10579 7 2 2 2 2885.00 0.00
10579 11 1 0 10 0.00 88.53
10579 11 2 11 24 1770.60 100.50
10579 11 3 25 34 7174.90 88.53
いくつかのクエリを試しましたが、成功しませんでした。誰かが私にそれを行う方法を提案できますか?
よろしくファブリツィオ