How to re-sort a sorted query?

Поиск
Список
Период
Сортировка
От Yudie
Тема How to re-sort a sorted query?
Дата
Msg-id 003001c4bb91$4c6647c0$a101a8c0@home.axiontech.com
обсуждение исходный текст
Ответы Re: How to re-sort a sorted query?
Список 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 по дате отправления:

Предыдущее
От: jboes@nexcerpt.com (Jeff Boes)
Дата:
Сообщение: How to recognize trigger-inserted rows?
Следующее
От: Wei Weng
Дата:
Сообщение: How do you compare (NULL) and (non-NULL)?