The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

SQL – count

SQL – count

0
Votes
1
Answer

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 Answer

365 Team
0
Votes

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

×
Online Data Science Training
SAVE 60%