How to re-sort a sorted query? - Mailing list pgsql-sql

From Yudie
Subject How to re-sort a sorted query?
Date
Msg-id 003001c4bb91$4c6647c0$a101a8c0@home.axiontech.com
Whole thread Raw
Responses Re: How to re-sort a sorted query?
List 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
 
 

pgsql-sql by date:

Previous
From: jboes@nexcerpt.com (Jeff Boes)
Date:
Subject: How to recognize trigger-inserted rows?
Next
From: Wei Weng
Date:
Subject: How do you compare (NULL) and (non-NULL)?