Home » Developer & Programmer » Forms » Detail Block Minimum values (oracle forms 10g)
Detail Block Minimum values [message #641324] Thu, 13 August 2015 06:16 Go to next message
knd.prasad
Messages: 35
Registered: December 2009
Location: HYDERABAD
Member
Hi,

I need to sum detail block minimum two values


data

emp_no empname salary
10001 ramesh 5000
10002 hari 3000
10003 kiran 6000
10004 vamsi 2000


I need to sum of 3000 and 2000


Thanks in Advance
prasad


Re: Detail Block Minimum values [message #641353 is a reply to message #641324] Thu, 13 August 2015 09:20 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Have you looked into the MIN() function? What have you tried - can you post an example of your code?
Re: Detail Block Minimum values [message #641379 is a reply to message #641324] Thu, 13 August 2015 23:11 Go to previous messageGo to next message
knd.prasad
Messages: 35
Registered: December 2009
Location: HYDERABAD
Member
I used Min() function but it gives only one value i.e, 2000
Re: Detail Block Minimum values [message #641381 is a reply to message #641379] Fri, 14 August 2015 00:32 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If those values are stored in a table, then you can run a query similar to this one (you'd probably have to include a condition which would join table values to the ones you see on the screen):
SQL> WITH test
  2       AS (SELECT 1 empno, 'ramesh' empname, 5000 salary FROM DUAL
  3           UNION ALL
  4           SELECT 2, 'hari', 3000 FROM DUAL
  5           UNION ALL
  6           SELECT 3, 'kiran', 6000 FROM DUAL
  7           UNION ALL
  8           SELECT 4, 'vamsi', 2000 FROM DUAL),
  9       ranked
 10       AS (SELECT empno,
 11                  empname,
 12                  salary,
 13                  RANK () OVER (ORDER BY salary) rnk
 14             FROM test)
 15  SELECT SUM (salary)
 16    FROM ranked
 17   WHERE rnk < 3;

SUM(SALARY)
-----------
       5000

SQL>


However, if those records are on the screen, then you'll have to loop through them, "manually" find the lowest two salaries (note that "two" doesn't necessarily mean "only two records" as several people can have the same salary) and sum them.
Re: Detail Block Minimum values [message #641383 is a reply to message #641381] Fri, 14 August 2015 01:01 Go to previous messageGo to next message
knd.prasad
Messages: 35
Registered: December 2009
Location: HYDERABAD
Member
I tried row_number() in db level it works fine but does not work in form level

Re: Detail Block Minimum values [message #641385 is a reply to message #641383] Fri, 14 August 2015 01:05 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That's true, because Forms' PL/SQL doesn't recognize analytic functions. Therefore, create a (stored) function of your own which would utilize analytic function and calculate the result, and then call that function from a form.
Re: Detail Block Minimum values [message #641432 is a reply to message #641385] Fri, 14 August 2015 12:57 Go to previous message
xebec
Messages: 37
Registered: July 2014
Location: Miraflores
Member
I agree with Littlefoot , you will need to create a sp (store_procedure) which analize and calculate the result.
You need to read the column or id o select something to recognize that part and them sum! Very Happy
Previous Topic: oracle jinitiator version too low mac please install version 1.1.8.2 or higher
Next Topic: Accounts Software
Goto Forum:
  


Current Time: Thu Apr 18 06:29:37 CDT 2024