1

Topic: Request correction in oracle sql

the new client who issued the order of 5/10/2018 of year.
It is necessary to fulfill a dry-cleaner of salon and a polish of headlights. To define
Preliminary cost of this order. What tables will be involved in
This transaction? - I am all made
But at me this order is deduced so that it consists of two services and for everyone preliminary cost separately is written
INSERT INTO KLIENT VALUES ((SELECT MAX (ID_K) +1 FROM KLIENT), ' Careful Dmitry Anatolevich ', 89316893325);
SELECT*FROM KLIENT;
INSERT INTO ZAKAZ VALUES ((SELECT MAX (ID_Z) +1 FROM ZAKAZ), 3, ' 10.05.18 ', ' 23.05.18 ',
(SELECT MAX (ID_K) FROM KLIENT), 3, (SELECT (price/100) *30 FROM USLUGI WHERE ID_U=3));
INSERT INTO ZAKAZ_USLUGI VALUES ((SELECT MAX (ID_Z) FROM ZAKAZ), 3);
INSERT INTO ZAKAZ VALUES ((SELECT MAX (ID_Z) FROM ZAKAZ), 6, ' 10.05.18 ', ' 15.05.18 ',
(SELECT MAX (ID_K) FROM KLIENT), 3, (SELECT (price/100) *30 FROM USLUGI WHERE ID_U=6));
INSERT INTO ZAKAZ_USLUGI VALUES ((SELECT MAX (ID_Z) FROM ZAKAZ), 6);
SELECT*FROM ZAKAZ;
SELECT*FROM ZAKAZ_USLUGI;
--Preliminary cost on each service separately
SELECT DISTINCT KLIENT.FIO, USLUGI.names, ZAKAZ.DATE_1, ZAKAZ.predvar_stoim
FROM KLIENT, USLUGI, ZAKAZ
WHERE KLIENT.ID_K = (SELECT MAX (ID_K) FROM KLIENT)
AND ZAKAZ.ID_Z = (SELECT MAX (ID_Z) FROM ZAKAZ WHERE USLUGI.ID_U=3)
AND ZAKAZ.predvar_stoim IN (SELECT predvar_stoim FROM ZAKAZ WHERE ID_U=3)
UNION
SELECT DISTINCT KLIENT.FIO, USLUGI.names, ZAKAZ.DATE_1, ZAKAZ.predvar_stoim
FROM KLIENT, USLUGI, ZAKAZ
WHERE KLIENT.ID_K = (SELECT MAX (ID_K) FROM KLIENT)
AND ZAKAZ.ID_Z = (SELECT MAX (ID_Z) FROM ZAKAZ WHERE USLUGI.ID_U=6)
AND ZAKAZ.predvar_stoim IN (SELECT predvar_stoim FROM ZAKAZ WHERE ID_U=6);
It is necessary for me, that preliminary cost was deduced from two these preliminary costs

2

Re: Request correction in oracle sql

Romchenk wrote:

  the new client who issued the order of 5/10/2018 of year.
It is necessary to fulfill a dry-cleaner of salon and a polish of headlights. To define
Preliminary cost of this order. What tables will be involved in
This transaction? - I am all made
But at me this order is deduced so that it consists of two services and for everyone preliminary cost separately is written

INSERT INTO KLIENT VALUES ((SELECT MAX (ID_K) +1 FROM KLIENT), ' Careful Dmitry Anatolevich ', 89316893325);
SELECT*FROM KLIENT;
INSERT INTO ZAKAZ VALUES ((SELECT MAX (ID_Z) +1 FROM ZAKAZ), 3, ' 10.05.18 ', ' 23.05.18 ',
(SELECT MAX (ID_K) FROM KLIENT), 3, (SELECT (price/100) *30 FROM USLUGI WHERE ID_U=3));
INSERT INTO ZAKAZ_USLUGI VALUES ((SELECT MAX (ID_Z) FROM ZAKAZ), 3);
INSERT INTO ZAKAZ VALUES ((SELECT MAX (ID_Z) FROM ZAKAZ), 6, ' 10.05.18 ', ' 15.05.18 ',
(SELECT MAX (ID_K) FROM KLIENT), 3, (SELECT (price/100) *30 FROM USLUGI WHERE ID_U=6));
INSERT INTO ZAKAZ_USLUGI VALUES ((SELECT MAX (ID_Z) FROM ZAKAZ), 6);
SELECT*FROM ZAKAZ;
SELECT*FROM ZAKAZ_USLUGI;
--Preliminary cost on each service separately
SELECT DISTINCT KLIENT.FIO, USLUGI.names, ZAKAZ.DATE_1, ZAKAZ.predvar_stoim
FROM KLIENT, USLUGI, ZAKAZ
WHERE KLIENT.ID_K = (SELECT MAX (ID_K) FROM KLIENT)
AND ZAKAZ.ID_Z = (SELECT MAX (ID_Z) FROM ZAKAZ WHERE USLUGI.ID_U=3)
AND ZAKAZ.predvar_stoim IN (SELECT predvar_stoim FROM ZAKAZ WHERE ID_U=3)
UNION
SELECT DISTINCT KLIENT.FIO, USLUGI.names, ZAKAZ.DATE_1, ZAKAZ.predvar_stoim
FROM KLIENT, USLUGI, ZAKAZ
WHERE KLIENT.ID_K = (SELECT MAX (ID_K) FROM KLIENT)
AND ZAKAZ.ID_Z = (SELECT MAX (ID_Z) FROM ZAKAZ WHERE USLUGI.ID_U=6)
AND ZAKAZ.predvar_stoim IN (SELECT predvar_stoim FROM ZAKAZ WHERE ID_U=6);

It is necessary for me, that preliminary cost was deduced from two these preliminary costs

Alexey,
1) re-read that you wrote, all is clear?
The people are lazy, and it not operation and if from the first does not understand, not everyone will understand further.
Try to write accurately and sequentially that on an input that on an output, instead of a consciousness flow
2) it is not necessary to mold screenshot, it is enough to copy the text, it is much more convenient if it is required to quote at the answer
3) the Text needs to be issued TAGS, they are for this purpose invented (buttons SRC, FIX, QUOTE... In window title)
Compare that was, and that became
4) If you want a prompt reply, prepare the test data that the answering could check up and result the answer to your data.
It will be convenient if the test data is in format WITH, in this case it is not required to create superfluous objects
Access to basis suffices.
For example (in your case):

WITH
USLUGI (id, names, preprice) AS (
SELECT 1, ' the Sink  ', 145 from dual union all
SELECT 2, ' the Sink  ', 245 from dual union all
SELECT 3, ' compression Straightening ', 124130 from dual
)
, KLIENT (ID_K, FIO, PHOME) AS (
select 22, ' Careful Dmitry Anatolevich ', 89316893325 from dual union all
select 12, ' Careful Anatoly Anatolevich ', 89316893323 from dual
)
, ZAKAZ (column1, column2...) AS (
...
)

5) Not absolutely on a subject, but a construction

INSERT INTO KLIENT VALUES ((SELECT MAX (ID_K) +1 FROM KLIENT)...

It will be very interesting to work if it will be caused simultaneously by some operators.
For the decision of this problem, there is an object of a DB sequence

create sequence s_klient_id;
INSERT INTO KLIENT VALUES (s_klient_id.nextval...

6) Well and on the sweet:
How correctly to ask questions