agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Bob Kruger <bkruger@mindspring.com>
To: pgsql-sql@postgresql.org
Subject: Query Question
Date: Wed, 16 Jun 1999 10:01:00 -0500
Message-ID: <3.0.5.32.19990616100100.007ac9a0@mindspring.com> (raw)
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
view thread (15+ messages) latest in thread
Message-ID: <3.0.5.32.19990616100100.007ac9a0@mindspring.com>
Permalink: ../3.0.5.32.19990616100100.007ac9a0@mindspring.com/
Also on: postgresql.org/message-id/3.0.5.32.19990616100100.007ac9a0@mindspring.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bkruger@mindspring.com
Subject: Re: Query Question
In-Reply-To: <3.0.5.32.19990616100100.007ac9a0@mindspring.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox