1

When I execute a query including arithmetic operations in the SELECT statement like:

SELECT a*5 FROM table; 

When a*5 will be executed in terms of the order of the query execution? I mean, is it before the ORDER BY, HAVING, and GROUP BY clauses? Or after or before all these?

Thanks in advance for your help.

MT0
  • 143,790
  • 11
  • 59
  • 117
general46
  • 800
  • 6
  • 16
  • Your query does not have an `ORDER BY`, `HAVING` or a `GROUP BY` clause. – MT0 Nov 03 '21 at 10:53
  • 1
    Does this answer your question? [Order Of Execution of the SQL query](https://stackoverflow.com/questions/4596467/order-of-execution-of-the-sql-query) – Stu Nov 03 '21 at 11:20
  • @Stu That question is for SQL Server and not Oracle; if you can find an equivalent question for Oracle then it maybe a duplicate (although this question is subtly different as it is talking about where in that order the arithmetic is evaluated). – MT0 Nov 03 '21 at 12:00
  • 1
    True it's tagged for Sqlserver but I think the principles apply to most platforms inc Oracle, there's also [this post](https://stackoverflow.com/questions/2842262/oracle-sql-clause-evaluation-order) – Stu Nov 03 '21 at 12:03
  • 1
    @Stu has it right. If the order of execution were different, the query language wouldn't be SQL, it would be something else. – O. Jones Nov 03 '21 at 15:35
  • @mT0 No it is not for SQL Server, it is for Oracle. – general46 Nov 06 '21 at 09:28

0 Answers0