- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
SELECT [IdPart],
[num],
NameRus AS PartName,
Rests,
Income,
Defect,
Rests +ISNULL([1],0) [1],
Rests +ISNULL([1],0)+ISNULL([2],0) [2],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0) [3],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0) [4],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0) [5],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)[6],
...
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)[11],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)[12],
...
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)[22],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)[23],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)[24],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)+ ISNULL([25],0)[25],
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)+ ISNULL([25],0)+ ISNULL([26],0)[26],
...
Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)+ ISNULL([25],0)+ ISNULL([26],0)+ ISNULL([27],0)+ ISNULL([28],0)+ISNULL([29],0)+ISNULL([30],0)+ISNULL([31],0)[31]
, Rests+Income-Defect + ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ [15]+ [16]+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)+ ISNULL([25],0)+ ISNULL([26],0)+ISNULL([27],0)+ISNULL([28],0)+ISNULL([29],0)+ISNULL([30],0)+ISNULL([31],0) AS TotalExpence
FROM
(
.....
Типа нарастающий итог. Ну слов просто нет. ИМХО, это что-то из разряда использовать микроскоп для забивания гвоздей.