Re: Query to get the min of the total - Mailing list pgsql-novice

From Marta Pérez Romero
Subject Re: Query to get the min of the total
Date
Msg-id CACnbkr=9bGSc2HBDb2-=WkLni_DUEVdhEikaFSTt5tXFyAgkzA@mail.gmail.com
Whole thread Raw
In response to Re: Query to get the min of the total  ("Oliveiros d'Azevedo Cristina" <oliveiros.cristina@marktest.pt>)
List 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.cristina@marktest.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

pgsql-novice by date:

Previous
From: "Oliveiros d'Azevedo Cristina"
Date:
Subject: Re: Query to get the min of the total
Next
From: James David Smith
Date:
Subject: Import CSV with Dates & Times