Inserting from a SELECT but changing one column?

前端 未结 6 758
忘了有多久
忘了有多久 2021-02-05 02:35

Wondering if there is a way to insert a row into a table from another, with exception of one column?

This is of course easy with a limitied amount of columns, but gets k

6条回答
  •  走了就别回头了
    2021-02-05 02:58

    zim RDBMS will allow it. All fields matching by fieldname will obtain values from the source, unless overridden by a let statement. eg.

        `add all details from details where account_month = 20190101 let level = 2 increase = base * 1.1 total = increase * amount`
    

    This would for all detail records for the specified accounting month, add a level 2 record with all field values matching the source set, except these assigned/calculated amounts: level is 2. increase is original base times 1.1. total is new increase (original base times 1.1) times the amount. If you switch the order of assignment of increase and total, then total will use the source/original increase in the calculation.

提交回复
热议问题