In Azure Stream analytics Query giving error in CASE statement
<p>I have some input data coming. There are 3 columns, fqn, v and t. The column v can have a string value or a number. If the fqn is like %production% then the v will be a number else it is a string. So I would have data like </p>

<pre><code>FQN,V,T
productioncount,23,time 
state,RUN,time 
productioncount,45,time etc
</code></pre>

<p>So I hve a case clause in the stream analytics query, but it looks like the other fqn's(which have v values like RUN etc) are also being processed. I get the following error </p>

<pre><code>"Cannot cast value 'RUN' to type 'bigint' in expression 'cast ( v as BIGINT )'.."
</code></pre>

<p>My query is as follows</p>

<pre><code>SELECT
 CASE
WHEN fqn like '%Production%' THEN ( max(cast(v as BIGINT))-(min(cast(v as BIGINT)))) 
ELSE MAX(V)
END AS V,
fqn,min(t) as timeslot
INTO
[finalalloutput]
FROM
[finalallinput] timestamp by t
group by TumblingWindow(minute, 1),fqn
</code></pre>

<p>Also I would like to change</p>

<pre><code>ELSE MAX(V)
</code></pre>

<p>to reflect the TOP value. Maybe Max(V) would also give me an error because it is a string.</p>