How to re-sort a sorted query?

From: "Yudie" <yudie(at)axiontech(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: How to re-sort a sorted query?
Date: 2004-10-26 19:23:30
Message-ID: 003001c4bb91$4c6647c0$a101a8c0@home.axiontech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a query that need to be sorted in order of price of store's product with unique store number.

Here is a sample data of storeproduct table:

ItemSku , StoreNumber , Price
==========================
10001 , 7 , 30.00
10001 , 7 , 35.00 <-- duplicate store number
10001 , 5 , 45.00
10001 , 2 , 50.00

Then I do this query to get unique store number and also the cheapest price from each store:

SQL= "Select distinct on (storenumber), itemsku, storenumber,price
from storeproduct where itemsku='10001'
order by storenumber, price"

Result #1:
ItemSku , StoreNumber , Price
10001 , 2 , 50.00
10001 , 5 , 45.00
10001 , 7 , 30.00

The question is how to make the query that returns as above but sorted by price?

Thanks..
Yudie

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Wei Weng 2004-10-26 20:23:20 How do you compare (NULL) and (non-NULL)?
Previous Message Jeff Boes 2004-10-26 17:00:01 How to recognize trigger-inserted rows?