Received: from smtp4.mindspring.com (smtp4.mindspring.com [207.69.200.64]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA25105 for ; Wed, 16 Jun 1999 11:01:18 -0400 (EDT) (envelope-from bkruger@mindspring.com) Received: from oplsrv3 (user-38h1to5.dialup.mindspring.com [209.16.247.5]) by smtp4.mindspring.com (8.8.5/8.8.5) with SMTP id LAA07673 for ; Wed, 16 Jun 1999 11:01:16 -0400 (EDT) Message-Id: <3.0.5.32.19990616100100.007ac9a0@mindspring.com> X-Sender: bkruger@mindspring.com X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.5 (32) Date: Wed, 16 Jun 1999 10:01:00 -0500 To: pgsql-sql@postgresql.org From: Bob Kruger Subject: Query Question Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Here is a simple query question that has me stumped. I have a database that contains the information on vehicle maintenance costs. When a repair is done to a vehicle, the tag number and the amount of the repair is recorded. table structure runs as follows: id serial po varchar(12) veh_no varchar(8) cost real comments varchar(30) I would like to be able to do a query in which I can list all of the vehicles and a totalization of the costs, e.g. list one vehicle number, and the sum of costs for that vehicle. Because there are numerous entries for each vehicle I know that some part of the query will have to include "distinct veh_no" so that only one output for each vehicle is listed. I have figured out a way to do this with Perl, but it takes two selects, and I would prefer to do this with just one. Any hints or ideas? Thanks in advance for any assistance. Regards - Bob Kruger