title: DECODE Oracle SQL
body: <p>I recently came across few decode queries.</p>
  
  <p>I found this decode function somewhat confusing. here are the queries:</p>
  
  <pre><code>SELECT promo_id,
         DECODE(NVL(promo_cost,0),promo_cost, promo_cost * 0.25, 100) "Discount"
  FROM promotions; 
  
  SELECT promo_id,
         DECODE(promo_cost,10000, DECODE(promo_category, 'G1', promo_cost *.25, NULL), NULL) "Catcost";
  </code></pre>
  
  <p>I went through the internet, studied some articles but it seems that DECODE is something that varies per query.</p>
  
  <p>Could anyone please explain to me what these two queries are doing.</p>
  
  <p>Thank you very much.</p>
  
  <p>Note: this is not my homework. I am a Musician by profession just took C and SQL recently as it is so interesting. </p>