Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Precedence of operators in SQL

$
0
0

I am using these two queries to fetch records whose salary is less than 1/10th of the 200000.

select first_name, last_name, salary from employee where salary < 200000 * 1/10select first_name, last_name, salary from employee where salary < 1/10 * 200000

The first query gives the required output(attached below in the image). But the second query doesn't gives any record in the output(no-error).

enter image description here

According to my understanding of precedence in SQL both query should work in same way. That division and multiplication operator should execute first than comparison operator.

Even, If I put parenthesis in the Second query, then also it's not giving any output.

select first_name, last_name, salary from employee where salary < ((1/10) * 200000)

So, why the Second query is not giving any output?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>