| Data Bases > Pgsql General > GROUP BY, ORDER... |
|
| << Topic |
< Post |
Post 1 of 3 Topic 15471 of 15987
|
Post > |
Topic >> |
GROUP BY, ORDER & LIMIT ?
by kynnjo@[EMAIL PROTECTED]
("Kynn Jones")
May 6, 2008 at 01:22 PM
|
------=_Part_18171_7523051.1210094550914
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Suppose table X has two columns: class (TEXT) and size (INT). I want a
listing showing the (up to) 5 largest values of "size" for each value of
"class" (for some values of "class" the total number of available records
may be less than 5).
What would be the simplest way to achieve such a listing? It seems like
something one could do with GROUP BY, ORDER, and LIMIT, but I can't figure
out the right syntax for this query.
Thanks!
Kynn
------=_Part_18171_7523051.1210094550914
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<br><div><br class="webkit-block-placeholder"></div><div><div><br
class="webkit-block-placeholder"></div><div><br
class="webkit-block-placeholder"></div><div>Suppose table X has two
columns: class (TEXT) and size (INT). I want a listing showing the
(up to) 5 largest values of "size" for each value of
"class" (for some values of "class" the total number
of available records may be less than 5).</div>
<div><br class="webkit-block-placeholder"></div><div>What would be the
simplest way to achieve such a listing? It seems like something one
could do with GROUP BY, ORDER, and LIMIT, but I can't figure out the
right syntax for this query.</div>
<div><br class="webkit-block-placeholder"></div><div>Thanks!</div><div><br
class="webkit-block-placeholder"></div><div>Kynn</div><div><br
class="webkit-block-placeholder"></div></div>
------=_Part_18171_7523051.1210094550914--


|
3 Posts in Topic:
|
kynnjo@[EMAIL PROTECTED]
|
2008-05-06 13:22:30 |
|
david.t.wilson@[EMAIL PRO |
2008-05-06 13:55:14 |
|
depesz@[EMAIL PROTECTED]
|
2008-05-06 20:04:08 |
|
Post A Reply:

|