BY listing_seq_id
) AS X ON X.listing_id= a.listing_id
ORDER by X.count DESC
R. Verghese
Author:Zac
Date: 2005-06-2905:122005-06-2912:12 -700UTC
To:pgsql-sql
Subject:Re: [SQL] ORDER
records based on parameters in IN clause
SELECT
table.*
FROM
table
JOIN (SELECT id, count(id) AS count FROM
On 6/30/05, M.D.G. Lange [EMAIL PROTECTED] wrote:
Another option would be:
SELECT * FROM table WHERE id=2003 OR id=1342 OR id=799 OR id=1450;
This should give you the results in the right order...
I don't think so...
create temporary table seq as select * from generate_series(1,20) as g(id);
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
fair enough. but a simple order by id would never work.
That was me, sorry, I must have been asleep when I wrote it. :)
- --
Greg Sabino Mullane [EMAIL PROTECTED]
PGP Key: 0x14964AC8 200506300636
On 6/27/05, Riya Verghese [EMAIL PROTECTED] wrote:
I have a stmt where the outer-query is limited by the results of the inner
query. I would like the outer query to return records in the same order as
the values provided in the IN clause (returned form the inner query).
The inner_query is
On Wed, Jun 29, 2005 at 07:19:22AM -0400, Russell Simpkins wrote:
Order by id will not do what you want, but this should.
Select * from table where id = 2003;
Union all
Select * from table where id = 1342;
Union all
Select * from table where id = 799;
Union all
Select * from table where
Riya Verghese wrote:
select * from table where id IN (2003,1342,799, 1450)
I would like the records to be ordered as 2003, 1342, 799, 1450. The
outer query has no knowledge of the count(id) that the inner_query is
ordering by.
I think this is the real problem: outer query must know count(id)
SELECT
table.*
FROM
table
JOIN (SELECT id, count(id) AS count FROM... your subquery) AS x
ORDER BY
x.count
Bye.
Sorry: I forgot join condition:
SELECT
table.*
FROM
table
JOIN (SELECT id, count(id) AS count FROM... your subquery) AS x ON
(table.id = x.id)
ORDER BY
fair enough. but a simple order by id would never work.
From: Michael Fuhr [EMAIL PROTECTED]
To: Russell Simpkins [EMAIL PROTECTED]
CC: pgsql-sql@postgresql.org
Subject: Re: [SQL] ORDER records based on parameters in IN clause
Date: Wed, 29 Jun 2005 05:57:23 -0600
On Wed, Jun 29, 2005 at 07:19
On Wed, 2005-06-29 at 09:22, Russell Simpkins wrote:
fair enough. but a simple order by id would never work.
Try this:
select *,
case
when id=2003 then 1
when id=1342 then 2
when id=799 then 3
when id=1450 then 4
On Mon, Jun 27, 2005 at 09:15:15AM -0700, Riya Verghese wrote:
I have a stmt where the outer-query is limited by the results of the
inner query. I would like the outer query to return records in the same
order as the values provided in the IN clause (returned form the inner
query).
If you
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
when I say
select * from table where id IN (2003,1342,799, 1450)
I would like the records to be ordered as 2003, 1342, 799, 1450.
Just say:
select * from table where id IN (2003,1342,799, 1450) ORDER BY id;
If that doesn't work, you will have
I have a stmt where the outer-query is limited by the
results of the inner query. I would like the outer query to return records in
the same order as the values provided in the IN clause (returned form the inner
query).
The inner_query is returning ids ordered by count(id)
, i.e by most
12 matches
Mail list logo