powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Firebird, InterBase [игнор отключен] [закрыт для гостей] / Сумма по строке в процедуре
6 сообщений из 6, страница 1 из 1
Сумма по строке в процедуре
    #38419634
freelance161
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Доброго времени суток!

Помогите с задачей, пожалуйста. Как собрать сумму (oper + toper + stoper) в такой процедуре:
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
begin
  for select
  dw.id,
  dw.number,
  dw.fio_full,
   COALESCE((select sum(low.salary)from link_operations_workers low
    inner join link_orders_operations loo on loo.id = low.id_link_orders_operations
    where dw.id = low.id_worker and loo.date_operations between :date_start and :date_end), 0) as oper,

    COALESCE((select sum(ltw.salary)from link_toperations_workers ltw
    inner join link_orders_toperations lot on lot.id = ltw.id_link_orders_toperations
    inner join di_time_operations dto on dto.id = lot.id_toperation
    where dw.id = ltw.id_worker
        and (lot.date_toperations between :date_start and :date_end)
        and dto.type_operation = 0), 0) as toper,

    COALESCE((select sum(ltw.salary)from link_toperations_workers ltw
    inner join link_orders_toperations lot on lot.id = ltw.id_link_orders_toperations
    inner join di_time_operations dto on dto.id = lot.id_toperation
    where dw.id = ltw.id_worker
        and (lot.date_toperations between :date_start and :date_end)
        and dto.type_operation = 1), 0) as stoper

  from di_workers dw
  where dw.id_unit = :id_unit
  group by dw.id, dw.number, dw.id_unit, dw.fio_full
  order by dw.fio_full
  into :id, :number, :fio_full, :sum_oper, :sum_toper, :sum_stoper
  do

  suspend;
end
...
Рейтинг: 0 / 0
Сумма по строке в процедуре
    #38419642
Фотография Симонов Денис
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
freelance161,

Код: plsql
1.
2.
3.
4.
5.
6.
7.
.............
  do
  begin
     all_sum = oper + toper + stoper;
     suspend;
  end
....................
...
Рейтинг: 0 / 0
Сумма по строке в процедуре
    #38419648
Ivan_Pisarevsky
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
select
  w.id,
  w.number,
  w.fio_full,
  w.oper,
  w.toper,
  w.stoper
  w.oper + w.toper + w.stoper  as all_oper
from
(select
  dw.id,
  dw.number,
  dw.fio_full,
   COALESCE((select sum(low.salary)from link_operations_workers low
    inner join link_orders_operations loo on loo.id = low.id_link_orders_operations
    where dw.id = low.id_worker and loo.date_operations between :date_start and :date_end), 0) as oper,

    COALESCE((select sum(ltw.salary)from link_toperations_workers ltw
    inner join link_orders_toperations lot on lot.id = ltw.id_link_orders_toperations
    inner join di_time_operations dto on dto.id = lot.id_toperation
    where dw.id = ltw.id_worker
        and (lot.date_toperations between :date_start and :date_end)
        and dto.type_operation = 0), 0) as toper,

    COALESCE((select sum(ltw.salary)from link_toperations_workers ltw
    inner join link_orders_toperations lot on lot.id = ltw.id_link_orders_toperations
    inner join di_time_operations dto on dto.id = lot.id_toperation
    where dw.id = ltw.id_worker
        and (lot.date_toperations between :date_start and :date_end)
        and dto.type_operation = 1), 0) as stoper

  from di_workers dw
  where dw.id_unit = :id_unit
  group by dw.id, dw.number, dw.id_unit, dw.fio_full
) w  
  order by w.fio_full
...
Рейтинг: 0 / 0
Сумма по строке в процедуре
    #38419696
freelance161
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Симонов Денис, спасибо!
Написал вот так:
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
begin
  for select
  dw.id,
  dw.number,
  dw.fio_full,
   COALESCE((select sum(low.salary)from link_operations_workers low
    inner join link_orders_operations loo on loo.id = low.id_link_orders_operations
    where dw.id = low.id_worker and loo.date_operations between :date_start and :date_end), 0) as oper,

    COALESCE((select sum(ltw.salary)from link_toperations_workers ltw
    inner join link_orders_toperations lot on lot.id = ltw.id_link_orders_toperations
    inner join di_time_operations dto on dto.id = lot.id_toperation
    where dw.id = ltw.id_worker
        and (lot.date_toperations between :date_start and :date_end)
        and dto.type_operation = 0), 0) as toper,

    COALESCE((select sum(ltw.salary)from link_toperations_workers ltw
    inner join link_orders_toperations lot on lot.id = ltw.id_link_orders_toperations
    inner join di_time_operations dto on dto.id = lot.id_toperation
    where dw.id = ltw.id_worker
        and (lot.date_toperations between :date_start and :date_end)
        and dto.type_operation = 1), 0) as stoper

  from di_workers dw
  where dw.id_unit = :par_id_unit
  group by dw.id, dw.number, dw.id_unit, dw.fio_full
  order by dw.fio_full
  into :id, :number, :fio_full, :sum_oper, :sum_toper, :sum_stoper
  do

  begin
     sum_all = :sum_oper + :sum_toper + :sum_stoper;
     suspend;
  end

  suspend;
end


Появилась другая проблема... Последняя строка стала дублироваться. Не подскажите как исправить?
...
Рейтинг: 0 / 0
Сумма по строке в процедуре
    #38419701
Tactical Nuclear Penguin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
убери suspend последний
...
Рейтинг: 0 / 0
Сумма по строке в процедуре
    #38420356
Фотография kdv
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
6 сообщений из 6, страница 1 из 1
Форумы / Firebird, InterBase [игнор отключен] [закрыт для гостей] / Сумма по строке в процедуре
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]