Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You just need to include your <code>CASE</code> in the <code>UPDATE</code> statement and not the local variable you were trying to use, like:</p> <pre><code>UPDATE VF_CasINV_Cost SET LeastOfThree = --&lt;&lt;your big case here where (CalendarYear = 2010) AND (Item# = Item#) AND (ID = ID) and (Item# &lt; 99999990) </code></pre> <p>so this is the final code:</p> <pre><code>UPDATE VF_CasINV_Cost SET LeastOfThree = CASE WHEN Market = Wgtd_Avg and Wgtd_Avg = LiFo THEN Market WHEN Lifo = 0 and Wgtd_Avg = 0 and Market &lt;&gt; 0 THEN Market WHEN Market &lt; LiFo AND Market &lt; Wgtd_Avg AND Market &lt;&gt; 0 THEN Market WHEN Market &lt;= Wgtd_Avg AND LiFo = 0 THEN Market WHEN Market &lt;= LiFo AND Wgtd_Avg = 0 THEN Market WHEN Market = 0 and Wgtd_Avg = 0 and LiFo &lt;&gt; 0 THEN LiFo WHEN LiFo &lt; Market AND LiFo &lt; Wgtd_Avg AND LiFo &lt;&gt; 0 THEN LiFo WHEN LiFo &lt;= Market AND Wgtd_Avg = 0 THEN LiFo WHEN LiFo &lt;= Wgtd_Avg AND Market = 0 THEN LiFo WHEN Market = 0 and LiFo = 0 and Wgtd_Avg &lt;&gt; 0 THEN Wgtd_Avg WHEN Wgtd_Avg &lt; Market and Wgtd_Avg &lt; LiFo and Wgtd_Avg &lt;&gt; 0 THEN Wgtd_Avg WHEN Wgtd_Avg &lt;= Market AND LiFo = 0 THEN Wgtd_Avg WHEN Wgtd_Avg &lt;= LiFo AND Market = 0 THEN Wgtd_Avg WHEN Market &lt;= LiFo and LiFo &lt; Wgtd_Avg and Market &lt;&gt; 0 THEN Market WHEN LiFo &lt;= Market and Market &lt; Wgtd_Avg and LiFo &lt;&gt; 0 THEN LiFo WHEN Wgtd_Avg &lt;= LiFo and LiFo &lt; Market and Wgtd_Avg &lt;&gt; 0 THEN Wgtd_Avg ELSE 0 END where (CalendarYear = 2010) AND (Item# = Item#) AND (ID = ID) and (Item# &lt; 99999990) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload