Re: Query to get the min of the total

From: Marta Pérez Romero <martape(at)gmail(dot)com>
To: "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Query to get the min of the total
Date: 2012-05-04 11:19:35
Message-ID: CACnbkr=9bGSc2HBDb2-=WkLni_DUEVdhEikaFSTt5tXFyAgkzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

The below works!!! I am investigating if it covers everything, but looks
good!
Thanks a mill!!!!

On 4 May 2012 12:12, Oliveiros d'Azevedo Cristina <
oliveiros(dot)cristina(at)marktest(dot)pt> wrote:

> SELECT *
> FROM
> (
> SELECT petname,SUM(quantity) as total
> FROM pets a
> NATURAL JOIN sales b
> GROUP BY petname
> ) x
> NATURAL JOIN
> (SELECT MIN(total) as total
> FROM
> (
> SELECT petname,SUM(quantity) as total
> FROM pets a
> NATURAL JOIN sales b
> GROUP BY petname
> )y
> )z
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message James David Smith 2012-05-04 11:38:12 Import CSV with Dates & Times
Previous Message Oliveiros d'Azevedo Cristina 2012-05-04 11:12:13 Re: Query to get the min of the total