This SQL operation will get the desired Proposal_ID.

SELECT P.Proposal_ID, 
AVG(c.Task_Good_Idea) AS Average 
FROM proposals P, 
proposal_appraisal c 
LEFT OUTER JOIN users b 
ON (c.Evaluator_ID = b.User_ID) 
LEFT OUTER JOIN submission_status d 
ON (c.Primary_Evaluation_Status_ID = d.submission_status_ID) 
WHERE (P.Proposal_ID = c.Proposal_ID) 
AND P.Proposal_ID >= 931 AND d.Submission_Status_ID = 2 
GROUP BY Proposal_ID 
HAVING Average >=25

How to modify the following SQL operation so that only desired Proposal_ID are used?

select cfp_Id, P.proposal_id, P.institution_Name, sum(P.Task_Good_Idea + P.Task_Involve_Youth + P.Task_Involve_Partnerships + P.Task_Exploit_Digital_Medium + P.Task_Value_For_Money + P.Task_Theme + P.Task_Skills_Development + P.Task_LOC_Curriculum) as Task_Good_Idea
from proposals P 
group by P.proposal_ID 
having (Task_Good_Idea >= 25) and (cfp_Id = 22) 
order by P.proposal_id desc

Recommended Answers

All 2 Replies

Please submit the table structure and some test data.

I think this is what you are after:

select cfp_Id, P.proposal_id, P.institution_Name, sum(P.Task_Good_Idea + P.Task_Involve_Youth + P.Task_Involve_Partnerships + P.Task_Exploit_Digital_Medium + P.Task_Value_For_Money + P.Task_Theme + P.Task_Skills_Development + P.Task_LOC_Curriculum) as Task_Good_Idea
from proposals P 
WHERE P.proposal_ID >=931
group by P.proposal_ID 
having (Task_Good_Idea >= 25) and (cfp_Id = 22) 
order by P.proposal_id desc
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.