Error in UPDATE FROM examples? "GROUP BY 2)"?
(1) By anonymous on 2022-01-27 15:54:53 [link] [source]
In your "UPDATE" page (https://sqlite.org/lang_update.html), at the section of "2.2 UPDATE FROM", there is this "GROUP BY 2)" in the example: UPDATE inventory SET quantity = quantity - daily.amt FROM (SELECT sum(quantity) AS amt, itemId FROM sales GROUP BY 2) AS daily WHERE inventory.itemId = daily.itemId; Is this "2)" should be "itemId"? Or maybe it is some sort of syntax I don't understand? It also appears in the other two examples in 2.2.1.
(2) By Stephan Beal (stephan) on 2022-01-27 15:57:32 in reply to 1 [source]
Or maybe it is some sort of syntax I don't understand?
It means to group by the 2nd column. That syntax also works for ORDER BY.