From: | "Riya Verghese" <riya(dot)verghese(at)admissioncorp(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | ORDER records based on parameters in IN clause |
Date: | 2005-07-07 21:01:39 |
Message-ID: | BBA4F47BB0CEDD4D8ADD2FE21E2823673116C5@dhost002-37.dex002.intermedia.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | PFC | 2005-07-07 22:26:30 | Re: getting back autonumber just inserted |
Previous Message | Michael Fuhr | 2005-07-07 20:57:25 | Re: getting back autonumber just inserted |