A0

Labels

Operators and Precedence in Oracle SQL

 

Operators

We can also use the operators while writing the queries eg +, -, *, / and ^. By using these operators we can display output in more accurate way for example if the salary for the employee is 500 per month and we want to display this salary for an year then by using the operators we can easily display the output. We can solve this query by multiplying the monthly salary with 12 months. After calculating output will be 500*12 =6000. 

Do you solve this?

2*3/5+1 

Maybe some people who did not know about the precedence of the operators they cannot solve this question . Therefore, I can help those people who do not know about the precedence of the operators.


Precedence of Operator:

                             *,/ has the same precedence and +,- has the same precedence which works from left to right. If we talk about the complete precedence then this will be like braces then power then divide and Multiply (works from left to right), plus and minus (works from left to right) .

So by following this precedence we can solve ever equation in Oracle SQL. Now we should solve the above equation which is 2*3/5+1.

Here firstly we will solve multiply part and solve it equation will be like 6/5+1 now we will solve division after this equation will 1.2+1 and after adding answer will be 2.2. I can also provide the screen shot for this question on SQL Plus. So the answer is

2*3/5+1
Here may be you are thinking what is dual don't worry dual is a dummy table which we uses in Oracle SQL for the answer. We can use this table when we are not dealing with the physical table in database. SO this was for today and stay connected with dowaste for more concepts related to Oracle SQL.


0 Comments:

Post a Comment