From: | "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt> |
---|---|
To: | Marta Pérez Romero <martape(at)gmail(dot)com> |
Cc: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Query to get the min of the total |
Date: | 2012-05-04 11:43:21 |
Message-ID: | 5F08417E3DDF46D7A429D1313E6F46D3@marktestcr.marktest.pt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Great to hear !!!
:-)
----- Original Message -----
From: Marta Pérez Romero
To: Oliveiros d'Azevedo Cristina
Cc: pgsql-novice(at)postgresql(dot)org
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(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
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2012-05-04 11:47:46 | Re: Import CSV with Dates & Times |
Previous Message | James David Smith | 2012-05-04 11:38:12 | Import CSV with Dates & Times |