Oracle SQL

Results 1 to 2 of 2

Thread: Oracle SQL

  1. #1
    Join Date
    Dec 1969

    Default Oracle SQL

    Hello,<BR><BR>Little bit confused about this Oracle SQL code. I would really appreciate if anybody explains this.<BR><BR>to_char(SUM(DECODE(SPUSER.FUNC1(ROUND (sysdate-TAB1.bus_dt,0)),1,TAB1.currency_amt,0)),&#039;999, 999,999.99&#039;) val1<BR><BR>Thanks

  2. #2
    Join Date
    Dec 1969

    Default RE: Oracle SQL

    ROUND(sysdate-TAB1.bus_dt,0)<BR><BR>returns the number of days between todays date and the date in the TAB1.bus_dt column.<BR><BR>SPUSER.FUNC1(ROUND(sysdate-TAB1.bus_dt,0))<BR><BR>A user defined function <BR><BR>Decode is a mapping function<BR><BR>e.g<BR><BR>Decode (e1,v1,r1,v2,r2,relse)<BR><BR>"works" as <BR> <BR>if e1 = v1 then<BR> r1<BR>elseif e1 = v2 then<BR> r2<BR>else<BR> relse<BR>end if<BR><BR>In your case, if the result of the spuser.func1 invocation is 1 then TAB1.currency_amt else 0. This is summed and then converted to character with format &#039;999,999,999.99&#039; i.e. present the result with 2 decimal digits and a , for each group of three digits.<BR><BR><BR>The value 234567.89 would be shown as<BR><BR>234,567.89 <BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts