havingQuery[1] - List the salespeople whose average order...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sample SQL query with the "having" clause (adapted from LAN Times Guide to SQL by James R. Groff and Paul N. Weinberg, Mc Graw Hill, 1994). Given the schema salesreps(empl_num,name,age,rep_office,title,hire_date,manager,quota,sales) orders(order_num,order_date,cust,rep,mfr,product,qty,amount) Foreign keys: orders.rep references salesreps.empl_num
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: List the salespeople whose average order size for products manufactured by XYZ is higher than overall average order size. select name, avg(amount) from salesreps, orders where empl_num = rep and mfr = 'XYZ' group by name having avg(amount) > (select avg(amount) from orders)...
View Full Document

Ask a homework question - tutors are online