Skip to content

Instantly share code, notes, and snippets.

@hackimov
Created November 20, 2020 12:28
Show Gist options
  • Select an option

  • Save hackimov/bde7f823934f869a901d3e64143f4805 to your computer and use it in GitHub Desktop.

Select an option

Save hackimov/bde7f823934f869a901d3e64143f4805 to your computer and use it in GitHub Desktop.

Revisions

  1. hackimov renamed this gist Nov 20, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. hackimov created this gist Nov 20, 2020.
    5 changes: 5 additions & 0 deletions UPDATE DOCUMENT TOTAL SUM
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    UPDATE documents set document_total_sum = tmp_sel.summa FROM
    (SELECT documents.document_id, cast(sum(vat_total_sum) as numeric(20,2)) as summa from documents LEFT JOIN value_params vp on documents.document_id = vp.document_id
    LEFT JOIN goods g on vp.value_param_id = g.value_param_id
    WHERE param_id = '78624016-1195-4301-8576-cfabead6c9c9' group by documents.document_id) as tmp_sel
    WHERE documents.document_id = tmp_sel.document_id;