Although you usually access a database to retrieve stored data, you often need to access calculations performed against data (and not the data itself). The SQL aggregate functions are a set of special functions that perform mathematical calculations against data, returning the results of those calculations to the calling application. The SQL aggregate functions are both powerful and flexible, and can be used in conjunction with tables, joins, and any other database features. TIP Many database developers find using the aggregate functions troublesome and even complex at times. So instead of using them, they retrieve large amounts of data and then programmatically perform the calculations themselves. This practice should be avoided at all costs. First, the database engine can process these calculations far quicker than any client application can. And second, sending unneeded data across a connection from a database server to a client host can have a significant effect on network traffic and performance. |