Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to solve this sql problem?

Status
Not open for further replies.

mokesql

Programmer
Sep 6, 2001
30
AT
cursor cur_sum_rest (wps_code d_wp_fond_wp.wfw_wps_code%type, rest_sum number) is select wfw_wps_code_teil
from d_wp_fond_wp
where wfw_wps_code = wps_code and wfw_wps_code_teil = 'N/A' and sum(wfw_anteil) = rest_sum
for update of wfw_gruppe;

i want to get id's of the combination which makes the sum that i give to the cursor. so if rest_sum is 30 i want to get this wfw_wps_code_teil's which together make the sum of 30. my problem is that its not allowed to use
sum(wfw_anteil) in the where clausel. is there a possibility to solve this another way? thnx for the help

kemo
 
Try this:

cursor cur_sum_rest (wps_code d_wp_fond_wp.wfw_wps_code%type, rest_sum number) is
SELECT wfw_wps_code_teil
FROM d_wp_fond_wp
WHERE wfw_wps_code = wps_code
AND wfw_wps_code_teil = 'N/A'
GROUP BY wfw_wps_code_teil
HAVING (wfw_anteil) = rest_sum;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top