// example showing how to call aggregate functions such as count(*), sum(*)

class Aggregator
{
   int count;
   double sum;
};

void AggregateExample()
{

   // count # of records in table DB_EXAMPLE
   // and grab sum of the DOUBLE_VALUE column

   Aggregator rowbuf;
   DBView<Aggregator> view_agg("DB_EXAMPLE", BCA(rowbuf, 
      COLS["COUNT(*)"] >> rowbuf.count && 
      COLS["SUM(DOUBLE_VALUE)"] >> rowbuf.sum)
   );

   Aggregator result = *view_agg.begin();
   cout << "There are " << result.count << " records in DB_EXAMPLE" << endl;
   cout << "The sum of the DOUBLE_VALUE column is " << result.sum << endl; 
}