中文网站
  Advanced Search
Read the latest Blogs from IT professionals in the field. Read and write community created documents. Need IT help? Ask our staff. Connect with your peers. Check our Tech Shop for posters, books and software tools. Home

5.1.7 Database Systems: Aggregate Operations

1. QBE includes the aggregate operators AVG, MAX, MIN, SUM and CNT. As QBE eliminates duplicates by default, they must have ALL. appended to them.

2. To find the total balance of all accounts belonging to Jones:

deposit bname account# cname balance
      Jones P.SUM.ALL.

3. All aggregate operators must have ALL. appended, so to override the ALL. we must add UNQ. (unique).(NOTE: a number of examples in the text incorrectly show UNQ. replacing ALL.)

deposit bname account# cname balance
  Main   P.CNT.UNQ.ALL.  

4. To compute functions on groups, we use the G. operator. To find the average balance at each branch:

deposit bname account# cname balance
  P.G.     P.AVG.ALL._x

5. To find the average balances at only branches where the average is more than $1,200, we add the condition box:

conditions
AVG.ALL. x > 1200

6. To find all customers who have an account at all branches located in Burnaby, we can do:

deposit bname account# cname balance
  _y   P.G._x  
branch bname assets bcity
 

_y

_z

 

Burnaby

Burnaby

conditions
CNT.UNQ.ALL. y =CNT.UNQ.ALL. z

Database System Structure: