powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Другие СУБД [игнор отключен] [закрыт для гостей] / Оптимизация SQL запроса
2 сообщений из 2, страница 1 из 1
Оптимизация SQL запроса
    #34068345
Smesh
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Помогите пожалуйста оптимизировать SQL запрос
Код: plaintext
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.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
 8 : 47   20 . 10 .2006insert into [oper]
      ([Kol],
       [Type],
       [nomtov])
select  0 ,
       "Приход",
       [id]
from   [Tovar] T1
where  (select count(*) from [Oper] O1 where O1.[nomtov]=T1.[id] and O1.[Type]="Приход")= 0 ;

insert into [oper]
      ([Kol],
       [Type],
       [nomtov])
select  0 ,
       "Расход",
       [id]
from   [Tovar] T1
where  (select count(*) from [Oper] O1 where O1.[nomtov]=T1.[id] and O1.[Type]="Расход") =  0 ;

insert into [oper]
      ([Kol],
       [Type],
       [nomtov])
select  0 ,
       "Резервирование",
       [id]
from   [Tovar] T1
where  (select count(*) from [Oper] O1 where O1.[nomtov]=T1.[id] and O1.[Type]="Резервирование") =  0 ;

update [tovar]
set 
[kol]=
(select Sum(kol) from [oper] o 
where o.[type]='Приход' and o.[nomtov]=[tovar].[id])-
(select Sum(kol) 
from [oper] o where o.[type]='Расход' and o.[nomtov]=[tovar].[id]),
[svobodno]=
(select Sum(kol) from [oper] o 
where o.[type]='Приход' and o.[nomtov]=[tovar].[id])-
(select Sum(kol) 
from [oper] o where o.[type]='Расход' and o.[nomtov]=[tovar].[id])-
(select Sum(kol) 
from [oper] o where o.[type]='Резервирование' and o.[nomtov]=[tovar].[id]),
[rezerv]=
(select Sum(kol) 
from [oper] o where o.[type]='Резервирование' and o.[nomtov]=[tovar].[id])
where dir=false;

delete from oper
where kol= 0 ; 
...
Рейтинг: 0 / 0
Оптимизация SQL запроса
    #34068893
WildSery
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Какой из пяти?
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / Другие СУБД [игнор отключен] [закрыт для гостей] / Оптимизация SQL запроса
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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