with Questions - TeradataQuestionsmost recent 30 from http://teradataquestions.com2010-09-09T15:43:34Zhttp://teradataquestions.com/feeds/tag/withhttp://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://teradataquestions.com/questions/68/decode-with-rownumDecode with RownumTDHelp2010-01-26T20:31:10Z2010-01-28T12:18:35Z
<p>Hi,</p>
<p>I have a requirement in Oracle using Decode function with Rownum. I need to convert this into Teradata. I need help in this. I tried using Top function and Rank qualify but unable to do the same. Please help me in this.</p>
<p>sample query in Oracle is:</p>
<pre><code>SELECT DECODE(ROWNUM, 1, party, 2, party, 3, party, 4, party, 5, party,6, party, 7,party,'Others') party,
mnth,SUM(qty) FROM
(
SELECT NVL(trim(b.Party_name),'Others') party, c.MONTH_ID mnth, SUM(a.qty) qty
FROM tablea a,tableb b,tablec c
WHERE a.col1 = b.col1
AND a.col2 = c.col1
AND a.col3='Y'
GROUP BY party,mnth
ORDER BY SUM(a.qty) DESC
)
GROUP BY DECODE(ROWNUM, 1, party, 2, party, 3, party, 4, party, 5, party, 6, party, 7, party, 'Others'),mnth
</code></pre>
<p>Please help me the conversion of outer query in Teradata. Thanks in Advance.</p>
<p>Thanks and Regards,
TDHelp.</p>