From: Riya Verghese <riya.verghese@admissioncorp.com>
To: pgsql-sql@postgresql.org
Subject: ORDER records based on parameters in IN clause
Date: Thu, 7 Jul 2005 14:01:39 -0700
Message-ID: <BBA4F47BB0CEDD4D8ADD2FE21E2823673116C5@dhost002-37.dex002.intermedia.net> (raw)
Thanks!
This worked beautifully.
Here's what I have:
SELECT a.listing_ id FROM cls.listings a
JOIN (SELECT listing_id,count(listing_id) AS count FROM cls.tagslistings
WHERE cust_id =27
AND tag_id IN (SELECT tag_id FROM cls.tags WHERE tag_name IN
('toys','263'))
GROUP 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-29 05:12
2005-06-29 12:12
-700
UTC
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... 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
x.count
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: riya.verghese@admissioncorp.com
Subject: Re: ORDER records based on parameters in IN clause
In-Reply-To: <BBA4F47BB0CEDD4D8ADD2FE21E2823673116C5@dhost002-37.dex002.intermedia.net>
References: <BBA4F47BB0CEDD4D8ADD2FE21E2823673116C5@dhost002-37.dex002.intermedia.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox