How to calculate an average and use that average to select some data?
e.g. for this query and its result.

select Proposal_ID, Mark, AVG(Mark) AS Average from proposal where (Proposal_ID >= 931) GROUP BY Proposal_ID
931        20         22.2222    
935        30         22.2222    
936        30         21.1111    
967        30         25.5556    
968        30         20.0000    
994        30         19.4444    
995        20         15.5556    
1010       30         17.7778    
1011       20         17.5000    
1015       20         17.7778    
1018       20         17.7778    
1020       30         18.8889    
1049       30         20.0000    
1050       30         22.5000    
1051       0          15.5556    
1052       10         17.7778    
1053       30         23.3333

How to refine the query so that after the average is calculated, then select those Proposal_ID where its average >= 20?

SELECT Proposal_ID, Mark, AVG(Mark) AS Average FROM proposal WHERE (Proposal_ID >= 931) GROUP BY Proposal_ID HAVING Average >= 20;
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.