X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8A4043A3B40 for ; Tue, 26 Oct 2004 20:25:02 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97206-03 for ; Tue, 26 Oct 2004 19:24:52 +0000 (GMT) Received: from axiontech.com (unknown [216.52.172.78]) by svr1.postgresql.org (Postfix) with SMTP id 049393A3AC9 for ; Tue, 26 Oct 2004 20:24:52 +0100 (BST) Received: (qmail 19153 invoked from network); 26 Oct 2004 19:25:03 -0000 Received: from pc-00161 (HELO yudie) (192.168.1.161) by mail.axiontech.com (192.168.1.6) with SMTP; 26 Oct 2004 19:25:03 -0000 Message-ID: <003001c4bb91$4c6647c0$a101a8c0@home.axiontech.com> From: "Yudie" To: Subject: How to re-sort a sorted query? Date: Tue, 26 Oct 2004 14:23:30 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002D_01C4BB67.5DAF1F40" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_50_60, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200410/186 X-Sequence-Number: 19289 This is a multi-part message in MIME format. ------=_NextPart_000_002D_01C4BB67.5DAF1F40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D 10001 , 7 , 30.00 10001 , 7 , 35.00 <-- duplicate store number=20 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=3D "Select distinct on (storenumber), itemsku, storenumber,price from storeproduct where itemsku=3D'10001'=20 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 p= rice? Thanks.. Yudie ------=_NextPart_000_002D_01C4BB67.5DAF1F40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I have a query that need to be sorted in o= rder of=20 price of store's product with unique store number.
 
Here is a sample data of storeproduct=20 table:
 
 
ItemSku , StoreNumber , Price<= /DIV>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D
10001 , 7 , 30.00
10001 , 7 , 35.00 <-- duplicate store n= umber=20
10001 , 5 , 45.00
10001 , 2 ,=20 50.00
 
Then I do this query to get unique store number and also the cheapest = price=20 from each store:
 
SQL=3D "Select distinct on (storenumber), itemsku, storenumber,price
from storeproduct where itemsku=3D'10001' 
order by storenumber, price"
 
Result #1:
ItemSku , StoreNumber ,=20 Price
<= FONT=20 face=3DArial size=3D2>
10001 , 2 ,=20 50.00
10001 , 5 , 45.00
10001 , 7 ,=20 30.00
 
The question is how to make the query that returns as above = but=20 sorted by price?
 
 
Thanks..
Yudie
 
 
------=_NextPart_000_002D_01C4BB67.5DAF1F40--