SELECT EMITENT FROM EMITENT WHERE EMITENT n_emit IN SELECT SERT_VIP n_

 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
52
53
54
55
56
57
58
59
60
SELECT EMITENT.*
FROM EMITENT
WHERE EMITENT.n_emit IN (
SELECT SERT_VIP.n_emit
FROM SERT_VIP
WHERE (
SERT_VIP.[n_vip] IN (SELECT OPER.N_VIP
FROM OPER
WHERE (DT_MOD BETWEEN DateValue('2000-01-01') AND DateValue('2000-12-31'))
AND
OPER.[KOD_OPER] = (SELECT KOD_OPER.[code]
FROM KOD_OPER
WHERE KOD_OPER.[name] LIKE "*Передача ЦБ между владельцами/ДУ*")
GROUP BY OPER.N_VIP
HAVING Count(OPER.N_VIP) >= (
SELECT TOP 1 Count(OPER.N_VIP)
FROM OPER
WHERE (
(OPER.DT_MOD Between DateValue('1999-01-01') And DateValue('1999-12-31'))
AND
OPER.KOD_OPER = (SELECT KOD_OPER.[code]
FROM KOD_OPER
WHERE KOD_OPER.[name] LIKE "*Передача ЦБ между владельцами/ДУ*")
)
GROUP BY OPER.N_VIP
ORDER BY 1 DESC;
)
ORDER BY OPER.N_VIP)
)
GROUP BY SERT_VIP.n_emit
);
// -----------------
SELECT EMITENT.*
FROM EMITENT
WHERE EMITENT.n_emit IN (
SELECT SERT_VIP.n_emit
FROM SERT_VIP
WHERE (
SERT_VIP.[n_vip] IN (
SELECT L_SCH.N_VIP
FROM L_SCH
WHERE NOT EXISTS (
SELECT *
FROM PERSON
WHERE (
PERSON.DEPO_SCH = L_SCH.DEPO_SCH AND
PERSON.TYP_PERS = (SELECT TYP_PERS.code
FROM TYP_PERS
WHERE TYP_PERS.name LIKE "*Залогодержатель*") AND
PERSON.TYP_DOC = (SELECT TYP_DOC.code
FROM TYP_DOC
WHERE TYP_DOC.name LIKE "*Ошибка в докум.*")
)
)
)
)
GROUP BY SERT_VIP.n_emit
);