agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Bob Kruger <bkruger@mindspring.com>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Query Question
Date: Wed, 16 Jun 1999 18:19:54 +0300
Message-ID: <l03130308b38d70ee3be5@[147.233.159.109]> (raw)
In-Reply-To: <3.0.5.32.19990616100100.007ac9a0@mindspring.com>

At 18:01 +0300 on 16/06/1999, Bob Kruger wrote:


>
> 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.

Do you mean

SELECT veh_no, sum( cost )
FROM the_table
GROUP BY veh_no;

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (15+ messages)  latest in thread

Message-ID: <l03130308b38d70ee3be5@[147.233.159.109]>
Permalink:  ../l03130308b38d70ee3be5@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130308b38d70ee3be5@[147.233.159.109]

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: herouth@oumail.openu.ac.il, bkruger@mindspring.com
  Subject: Re: [SQL] Query Question
  In-Reply-To: <l03130308b38d70ee3be5@[147.233.159.109]>

* 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