math in query vs math in app
Posted in 1994
There was a suggestion in the FAQ to move math from the query to the application. The example given involved multiplying a column by a constant. Does the suggestion also hold for math involving several columns in the same table? For example, I have a table that holds the cost, the beginning count and the ending count. Which way is more efficient: 1. SELECT (end - begin) * cost INTO final_cost FROM TABLE or 2. SELECT begin, end, cost INTO table.begin, table.end, table.cost FROM TABLE LET final_cost = (table.end - table.begin) * table.cost Before reading the FAQ, I would have written it the first way, since I was taught to select what I wanted, but the FAQ seems to indicate the second way would be better. Thanks in advance.