Jump to content

Snow Brothers Sunny Leone Ni Esara..


Recommended Posts

Posted
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..

 

  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

  • babugaru

    16

  • spidereddy

    15

  • ipaddress0

    2

  • sompapidi

    2

Top Posters In This Topic

Posted

Yes man threesome anta
Idhi enti daani rate details ?

Posted

 

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
Posted

work aithundo ledho cheppu try chesi .. ilanti vishayllo blood pedatha nenu :P

Posted

 

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..

Posted

wht is this mayya

papam babu help kavali annadu baa .. anduke naaku telisina danlo edo koosintha help chesthunna

Posted

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..

Posted

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

Posted

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 

Posted

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..

×
×
  • Create New...