- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 100
select x1.g_id,
(select switch(
str='0','новое строительство',
str='1','подготовка территории',
str='2','реконструкция',
str='3','снос' )
from t1
where g_id=x1.p_id
and f_id in(1,71,81)
and id=1),
(select switch(
str='0','административное здание',
str='1','детский сад',
str='2','дорога',
str='3','жилое здание',
str='4','инженерные сети',
str='5','коммуникации',
str='6','поликлиника',
str='7','путепровод',
str='8','ЦТП',
str='9','школа') from t1
where g_id=x1.p_id
and f_id in(1,71,81)
and id=2),
(select 'Субъект '+
(select str from subj
where type1=1
and id1=int(x3.str))+
switch(
x4.str='0',', город ',
x4.str='1',', деревня ',
x4.str='2',', ПГТ ',
x4.str='3',', поселок ',
x4.str='4',', село ')+
(select str from subj
where type1=3
and id1=int(x5.str))+iif(x6.str,
(select ', '+str from subj
where type1=2
and id1=int(x6.str)),'')+iif(x7.str,
(select ', '+str from subj
where type1=5
and id1=int(x7.str)),'')+iif(x8.str,',микр.'+x8.str,'')+iif(x9.str,', квартал '+x9.str,'')+iif(x10.str,', жил.группа '+x10.str,'')+
(select Format(', '+str) from t1
where f_id in(1,71,81)
and id=12
and g_id=x1.p_id)+iif(x11.str,', вл.'+x11.str,'')+iif(x12.str,', д.'+x12.str,'')+iif(x13.str,', кор.'+x13.str,'')+iif(x14.str,', стр.'+x14.str,'')
from t1 as x3,t1 as x4,t1 as x5,t1 as x6,t1 as x7,t1 as x8,t1 as x9,t1 as x10,t1 as x11,t1 as x12,t1 as x13,t1 as x14
where x3.f_id in(1,71,81)
and x3.id=4
and x3.g_id=x1.p_id
and x4.f_id=x3.f_id
and x4.id=7
and x4.g_id=x3.g_id
and x5.f_id=x3.f_id
and x5.id=8 and x5.g_id=x3.g_id
and x6.f_id=x3.f_id
and x6.id=5
and x6.g_id=x3.g_id
and x7.f_id=x3.f_id
and x7.id=6
and x7.g_id=x3.g_id
and x8.f_id=x3.f_id
and x8.id=9
and x8.g_id=x3.g_id
and x9.f_id=x3.f_id
and x9.id=10
and x9.g_id=x3.g_id
and x10.f_id=x3.f_id
and x10.id=11
and x10.g_id=x3.g_id
and x11.f_id=x3.f_id
and x11.id=13
and x11.g_id=x3.g_id
and x12.f_id=x3.f_id
and x12.id=14
and x12.g_id=x3.g_id
and x13.f_id=x3.f_id
and x13.id=15
and x13.g_id=x3.g_id
and x14.f_id=x3.f_id
and x14.id=16
and x14.g_id=x3.g_id),
(select code1 from fkko,t1
where id1=int(t1.str)
and g_id=x1.g_id
and f_id=x1.f_id
Запрос по теме "Помогите ускорить базу".
Взято здесь: http://sql.ru/forum/actualthread.aspx?bid=4&tid=656930