'BigQuery Count (*) isn't adding up to actual total

I'm trying to get a query to return the total count for Fri-Sun. The actual counts and total are:

  • Fri: 406,373
  • Sat: 432,196
  • Sun: 376,253
  • TOTAL: 1,214,822

When I run this query:

SELECT 
COUNT (*)
FROM `project.dataset.abcxyz`
WHERE start_day_of_week = "Fri" OR
start_day_of_week = "Sat" OR
start_day_of_week = "Sun"

It returns 2,661,777. When I run the days one at a time, I get the known actual counts. Where am I going wrong combining them?

Thank you!

Edit: Thank you for the help and suggestions. When I copied and pasted my code above, I missed my last line, which is: AND start_tourism_in_out = "Inside"

I tried all of the suggestions everyone made and was still having trouble getting to the known numbers. So I googled some more and came across someone saying to use parentheses around multiple conditions if they're queried on the same column, so I did that around the start_day_of_week OR conditions and it worked.

The final code is:

SELECT 
COUNT (*)
FROM `cyclistic-2021apr-2022mar.2021apr2022mar.cyclisticall`
WHERE (start_day_of_week = "Fri" OR 
start_day_of_week = "Sat" OR
start_day_of_week = "Sun") AND
start_tourism_in_out = "Inside"

Query returned: 1,214,822

Thanks again!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source