ใช่ตัว  having หรือเปล่าครับ
ตัวนี้เราจะใช้ในการกำหนดเงื่อนไขของฟังก์ชัน เช่น sum , avg , count
ปกติเราใส่เงื่อนไข  เราจะใส่ตรง  where  แต่ถ้าเงื่อนไขที่เรากำหนดเป็นฟังก์ชัน  เราต้องใช้ having ครับ  
ดูตัวอย่างจากโค้ดนี้ก็ได้ครับ
select hn,count(*) as cc,sum(income) as ss,age_y from an_stat
where dchdate between "2010-05-01" and "2010-05-30"
group by hn
order by cc desc
limit 10
โค้ดนี้เป็นการดึงข้อมูลผู้ป่วยใน  10  อันดับแรกที่  ดิสชาจ ในเดือน พฤษภา บ่อยที่สุด
โดยดึง  hn , จำนวนครั้งที่มา dischage , รวมค่ารักษาของคนนั้น , อายุ
ถ้าเราจะกรองอายุ  ก็ต้องใส่เงื่อนไขใน where  เช่นจะเอาอายุมากกว่่า  10  ปี  โค้ดก็จะเป็นดังนี้
select hn,count(*) as cc,sum(income) as ss,age_y from an_stat
where dchdate between "2010-05-01" and "2010-05-30" and age_y > 10
group by hn
order by cc desc
limit 10
แต่ถ้าเราจะกรองค่าใช้จ่ายรวมที่มากกว่า  5000  ต้องใช้  having เนื่องจากฟิลนี้ใช้ฟังก์ชัน  sum
select hn,count(*) as cc,sum(income) as ss,age_y from an_stat
where dchdate between "2010-05-01" and "2010-05-30" 
group by hn
having ss > 5000
order by cc desc
limit 10