Using IF in BigQuery SQL
<p><strong>Case</strong>: I have Sales table in BQ and item_num column contains values 1, -1 and 0. I want to count how many cases I have for each value.</p>

<p>Tried a simple query below, but count returns exactly the same number for each case.. What I am missing?</p>

<pre><code>SELECT 
count(if(item_num &gt; 0,1, 0)) as buysplus,
count(if(item_num &lt; 0,1, 0)) as buysminus,
count(if(item_num = 0,1, 0)) as buyszero
from MyShop.Sales
</code></pre>

<p>thanks</p>