Answer the question
In order to leave comments, you need to log in
How to correctly complete a SQL query?
Hello, tell me how to correctly supplement this query so that between the columns years and summa2 there is a column percent, which will contain the percentage by how much the value of summa has changed relative to summa2 as a percentage?
SELECT reservtable.sudovlad, reservtable.summa, reservtable.years, reservtable2.summa2, reservtable2.years2
FROM(
SELECT sudovlad, Sum(gruz_pass) AS summa, Extract(YEAR from data_vih_p_ot ) AS years
FROM ships WHERE sudovlad = 'pere'
GROUP by Extract(YEAR from data_vih_p_ot )
) reservtable,
(SELECT sudovlad, Sum(gruz_pass) AS summa2, Extract(YEAR from data_vih_p_ot ) AS years2
FROM ships WHERE sudovlad = 'pere'
GROUP by Extract(YEAR from data_vih_p_ot )
) reservtable2
WHERE reservtable.years=2018 AND reservtable2.years2=2017
Answer the question
In order to leave comments, you need to log in
I, in general, am on the side of the base, I would not carry out such calculations
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question