Home » SQL & PL/SQL » SQL & PL/SQL » max(decode) v/c sum(decode)
max(decode) v/c sum(decode) [message #210560] Thu, 21 December 2006 05:40 Go to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
hello all

can anybody tell me what is the difference between max(decode)
and sum(decode)?

i have done a query where i found nothing difference between them.

SQL> ed
Wrote file afiedt.buf
  1  select territory,
  2  max(decode(MON, 'dec', count))dec,
  3  max(decode(MON, 'jan', count))jan
  4  from(
  5  select territory, to_char(creation_date, 'mon')MON, sum(count)count
  6  from territory
  7  group by (territory, to_char(creation_date, 'mon'))
  8  )
  9* group by territory
SQL> /

 TERRITORY        DEC        JAN
---------- ---------- ----------
         1
         3                    15
         6         20
SQL> ed
Wrote file afiedt.buf

  1  select territory,
  2  sum(decode(MON, 'dec', count))dec,
  3  sum(decode(MON, 'jan', count))jan
  4  from(
  5  select territory, to_char(creation_date, 'mon')MON, sum(count)count
  6  from territory
  7  group by (territory, to_char(creation_date, 'mon'))
  8  )
  9* group by territory
SQL> /

 TERRITORY        DEC        JAN
---------- ---------- ----------
         1
         3                    15
         6         20



please make me clear or atleast provide me some link from where i will get help.

with regards
ishika
Re: max(decode) v/c sum(decode) [message #210573 is a reply to message #210560] Thu, 21 December 2006 06:26 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
If your subquery only returns 1 row per territory, then of course your max equals your sum.
Re: max(decode) v/c sum(decode) [message #210641 is a reply to message #210560] Thu, 21 December 2006 11:46 Go to previous messageGo to next message
ishika_20
Messages: 339
Registered: December 2006
Location: delhi
Senior Member
hello frank

can u give me some more link, from where i get to know more about decode.

please provide me help.

regards
ishika
Re: max(decode) v/c sum(decode) [message #210646 is a reply to message #210641] Thu, 21 December 2006 12:01 Go to previous message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
The expected response to this would be to do a search for decode.
Previous Topic: Argh, some help please
Next Topic: about text
Goto Forum:
  


Current Time: Sat Dec 03 08:02:41 CST 2016

Total time taken to generate the page: 0.15774 seconds