I have a very large view which uses case statements. In each case are 
subqueries which preforms a sort of validation. However depending on if the 
result is not zero it will do the same subquery over again;

CASE 
  WHEN (
    SELECT Sum(Total) 
      FROM Schema.Hours a 
      WHERE a.ID = Hours.ID 
      AND Rank = 1) > 0
    THEN (
      SELECT Sum(Total) 
      FROM Schema.Hours a 
      WHERE a.ID = Hours.ID 
      AND Rank = 1)
  ELSE 0
  END RankGroup

If I use a decode function how would I be able to compare the query's value 
being greater than zero, than putting the value as the result? As of right now 
I compare the query to check if it's equal to zero, which is not good in my 
opinion. This is what I have so far:

  DECODE(  
    (SELECT Sum(Total) 
      FROM Schema.Hours a 
      WHERE a.ID = Hours.ID 
      AND Rank = 1), 
    0, 0, ??????) AS RankGroup

Any help or suggestions are appreciated. Thanks!






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us

Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2982
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6

Reply via email to