Skip to content

Instantly share code, notes, and snippets.

@montreal91
Created December 18, 2015 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save montreal91/d5c42d1e4cfb2bf5cda3 to your computer and use it in GitHub Desktop.
Save montreal91/d5c42d1e4cfb2bf5cda3 to your computer and use it in GitHub Desktop.
insert
INSERT INTO nay_computatuon(n_computation, d_computation, n_tariff, n_info_hot, n_info_cold, n_pay, n_sum_hot, n_sum_cold, n_client, n_total, n_debt, n_difference_hot, n_difference_cold)
VALUES (
SELECT DISTINCT nay_computation.d_computation, 21 AS n_tariff, (
SELECT round(avg(n_info_hot), 0)
FROM nay_computation
) AS info_hot,(
SELECT round(avg(n_info_cold), 0)
FROM nay_computation
) AS info_cold, (
SELECT round(avg(n_pay),0)
FROM nay_computation
) AS pay, (
SELECT round(avg(n_sum_hot), 0)
FROM nay_computation
) AS sum_hot, (
SELECT round(avg(n_sum_cold), 0)
FROM nay_computation
) AS sum_cold, max(nay_client.n_client), (
SELECT round(avg(n_total),0)
FROM nay_computation
) AS total, (
SELECT round(avg(n_debt),0)
FROM nay_computation
) AS debt, (
SELECT round(avg(n_difference_hot), 0)
FROM nay_computation
) AS dif_hot, (
SELECT round(avg(n_difference_cold), 0)
FROM nay_computation
) AS dif_cold
FROM nay_computation, nay_client, nay_tariff
GROUP BY nay_computation.d_computation
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment