1回答
- 新しい順
- 投票が多い順
- コメントが多い順
0
I hope this is helpful for you.
SELECT
(final - inicial) / final AS variacion,
c.comuna,
inicial,
final
FROM
codigo_comuna_region AS c
INNER JOIN (
SELECT
cod_com,
count(numero_linea) AS inicial,
(
SELECT
count(numero_linea)
FROM
const
WHERE
periodo = '1-2021' AND
cod_com = c1.cod_com
) AS final
FROM
const AS c1
WHERE
periodo = '1-2011'
GROUP BY
cod_com
) AS d ON c.cod_com = d.cod_com
ORDER BY
variacion DESC
LIMIT
10;
回答済み 1年前
It doesn't work for me, I get a column filled with 0 in variation, and it doesn't order it in DESC by variation because when I run the code a second time it gives me a different result than the first.
my "initial and final column" is not a column from the database, it is a column that I did through a select, because the data of the initial and final column are together in a "period" column
The title language seems to be Spanish, so modify it in English so your might get an answer sooner.