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

From Oliveiros d'Azevedo Cristina
Subject Re: Query to get the min of the total
Date
Msg-id 5F08417E3DDF46D7A429D1313E6F46D3@marktestcr.marktest.pt
Whole thread Raw
In response to Query to get the min of the total  (Marta Pérez Romero <martape@gmail.com>)
List pgsql-novice
Great to hear !!!
:-)
----- Original Message -----
Sent: Friday, May 04, 2012 12:19 PM
Subject: Re: [NOVICE] Query to get the min of the total

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: James David Smith
Date:
Subject: Import CSV with Dates & Times
Next
From: Simon Riggs
Date:
Subject: Re: Import CSV with Dates & Times