Re: ASK about SQL

From: "Phillip Smith" <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
To: "'ali nas'" <ali_llg21(at)yahoo(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: ASK about SQL
Date: 2007-05-31 09:17:31
Message-ID: 01cd01c7a364$85198dd0$9b0014ac@wbaus090
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Yes, you can order it the same as how you've listed in the IN condition, but
you need to use the ORDER BY clause... Essentially you just need to pass the
same list to both IN and ORDER BY but with some slightly different
formatting...

SELECT ean
FROM icitem
WHERE ean IN (4902715720005, 4909411012151, 4909411010164, 4902715688718,
4902715731605, 4909411008864, 4909411010188, 4909411010126, 4909411010140,
4909411012052, 4902715720104, 4909411010089, 4909411010201, 0)
ORDER BY CASE WHEN ean = 4902715720005 THEN '1'
WHEN ean = 4909411012151 THEN '2'
WHEN ean = 4909411010164 THEN '3'
WHEN ean = 4902715688718 THEN '4'
WHEN ean = 4902715731605 THEN '5'
WHEN ean = 4909411008864 THEN '6'
WHEN ean = 4909411010188 THEN '7'
WHEN ean = 4909411010126 THEN '8'
WHEN ean = 4909411010140 THEN '9'
WHEN ean = 4909411012052 THEN '10'
WHEN ean = 4902715720104 THEN '11'
WHEN ean = 4909411010089 THEN '12'
WHEN ean = 4909411010201 THEN '13'
WHEN ean = 0 THEN '14'
;

-----Original Message-----
From: ali nas [mailto:ali_llg21(at)yahoo(dot)com]
Sent: Thursday, 31 May 2007 18:57
To: Phillip Smith
Subject: Hal: [SQL] ASK about SQL

YES, I don't care with with ORDER BY clause. beacuse i just want what the
data INPUT as like that the data OUTPUT ,so INPUT listed = OUTPUT listed.
so there isn't way in POSTGRES to do like this ??

----- Pesan Asli ----
Dari: Phillip Smith <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
Kepada: ali nas <ali_llg21(at)yahoo(dot)com>
Terkirim: Kamis, 31 Mei, 2007 3:44:12
Topik: RE: [SQL] ASK about SQL

You will need to explicitly tell Postgres what order you want it in - unless
you tell PG the order you want with an ORDER BY clause, it assumes you don't
care.

I can't recall 100% the exact syntax for the ORDER BY in your case, but
someone else more with it than me at the moment will be able to... Hang
tight! :)

-----Original Message-----
From: ali nas [mailto:ali_llg21(at)yahoo(dot)com]
Sent: Thursday, 31 May 2007 18:31
To: Phillip Smith
Subject: Hal: [SQL] ASK about SQL

THX's for answered my question.

YES, i want POSTGRES just do SELECT in the IN condition. add clue, POSTGRES
will show the SELECT data which POSTGRES find first. I dont wanna like that.
So what will I do ??

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee. If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by
Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments


________________________________________________________
Kunjungi halaman depan Yahoo! Indonesia yang baru!
http://id.yahoo.com/

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee. If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2007-05-31 10:22:40 Re: slow query execution
Previous Message Trigve Siver 2007-05-31 08:42:00 Re: slow query execution