Last answered:

05 Apr 2020

Posted on:

04 Apr 2020

0

Resolved: SQL - count

Hi, What is the different in these two? How come I'm getting a different answer?   select count(salary >= '100000') from salaries;

select count(*) from salaries
where salary >='100000' ;
1 answers ( 0 marked as helpful)
Instructor
Posted on:

05 Apr 2020

0
Hi Pui! Thanks for reaching out! You are getting a different answer because of the rules set by the MySQL syntax, so to speak. Therefore, there's not too much logic to look for here - there are rules to learn and stick to. The first query you have isn't really complying with the MySQL syntax, because this is not the way to specify a condition. The way to do that is, as you've done in the second query, with the help of a WHERE clause. Hope this helps.
Best,
Martin

Submit an answer