spidereddy Posted October 22, 2014 Report Posted October 22, 2014 sry for misleading title.. select decode(sal_1,0,null, (sum(case when date_key between to_char(add_months(sysdate,-12),'YYYYMM') and to_char(sysdate,'YYYYMM') then salary/sal_1 end))) as annual_sal from employee group by emp_key,sal_1; or select case when sal_1<>0 then sum(case when date_key between to_char(add_months(sysdate,-12),'YYYYMM') and to_char(sysdate,'YYYYMM') then salary/sal_1 end)end as annual_sal from employee group by emp_key,sal_1; paina queries execute chesthe 'divisor is equal to zero' error osthundhi.. if i add a filter condition to consider only positive values..then its working.. select case when sal_1<>0 then sum(case when date_key between to_char(add_months(sysdate,-12),'YYYYMM') and to_char(sysdate,'YYYYMM') then salary/sal_1 end)end as annual_sal from employee group by emp_key,sal_1; but i want to get the same result for negative values too..
kiladi bullodu Posted October 22, 2014 Report Posted October 22, 2014 Yes man threesome anta Idhi enti daani rate details ?
babugaru Posted October 22, 2014 Report Posted October 22, 2014 sry for misleading title.. select decode(sal_1,0,null, (sum(case when date_key between to_char(add_months(sysdate,-12),'YYYYMM') and to_char(sysdate,'YYYYMM') then salary/sal_1 end))) as annual_sal from employee group by emp_key,sal_1; or select case when sal_1<>0 then sum(case when date_key between to_char(add_months(sysdate,-12),'YYYYMM') and to_char(sysdate,'YYYYMM') then salary/sal_1 end)end as annual_sal from employee group by emp_key,sal_1; paina queries execute chesthe 'divisor is equal to zero' error osthundhi.. if i add a filter condition to consider only positive values..then its working.. select case when sal_1<>0 then sum(case when date_key between to_char(add_months(sysdate,-12),'YYYYMM') and to_char(sysdate,'YYYYMM') then salary/sal_1 end)end as annual_sal from employee group by emp_key,sal_1; but i want to get the same result for negative values too.. SELECT DECODE ( sal_1, 0, NULL, (SUM(CASE WHEN date_key BETWEEN TO_CHAR ( ADD_MONTHS (SYSDATE, -12), 'YYYYMM' ) AND TO_CHAR (SYSDATE, 'YYYYMM') THEN salary / sal_1 END)) ) AS annual_sal FROM employee GROUP BY emp_key, sal_1; NULL value osthundi emo adi kuda handle cheyyi
babugaru Posted October 22, 2014 Report Posted October 22, 2014 I mean sal_1 value NULL ocche chances undaoccha ?
babugaru Posted October 22, 2014 Report Posted October 22, 2014 work aithundo ledho cheppu try chesi .. ilanti vishayllo blood pedatha nenu :P
spidereddy Posted October 22, 2014 Author Report Posted October 22, 2014 SELECT DECODE ( sal_1, 0, NULL, (SUM(CASE WHEN date_key BETWEEN TO_CHAR ( ADD_MONTHS (SYSDATE, -12), 'YYYYMM' ) AND TO_CHAR (SYSDATE, 'YYYYMM') THEN salary / sal_1 END)) ) AS annual_sal FROM employee GROUP BY emp_key, sal_1; NULL value osthundi emo adi kuda handle cheyyi nu em changes cheshnavo nak ardam katle bhayya..koncham xplain pls..
babugaru Posted October 22, 2014 Report Posted October 22, 2014 wht is this mayya papam babu help kavali annadu baa .. anduke naaku telisina danlo edo koosintha help chesthunna
spidereddy Posted October 22, 2014 Author Report Posted October 22, 2014 I mean sal_1 value NULL ocche chances undaoccha ? yep sal_1 null oche chance undhi..andhke case statement petta kada 'case when sal_1 <> 0' ani..
babugaru Posted October 22, 2014 Report Posted October 22, 2014 nu em changes cheshnavo nak ardam katle bhayya..koncham xplain pls.. lol .. nenu em change cheyyale .. nuvvu icchina first query baga confusing ga undi anduke first danni format chesa.. So nuvvu sal_1 value '0' aithe condition ni handle chesthunnav kaani sal_1 value NULL aithe still fail aithadi kada. SO decode lo aan condition add chesi try cheyyamantunna
babugaru Posted October 23, 2014 Report Posted October 23, 2014 yep sal_1 null oche chance undhi..andhke case statement petta kada 'case when sal_1 <> 0' ani.. 0 untadatam veru NULL undatam veru babji
spidereddy Posted October 23, 2014 Author Report Posted October 23, 2014 lol .. nenu em change cheyyale .. nuvvu icchina first query baga confusing ga undi anduke first danni format chesa.. So nuvvu sal_1 value '0' aithe condition ni handle chesthunnav kaani sal_1 value NULL aithe still fail aithadi kada. SO decode lo aan condition add chesi try cheyyamantunna 2nd query chudu..
Recommended Posts