Problem with getting the right order

From: Henrik Pedersen <HenrikP(at)mail(dot)ikasths(dot)dk>
To: pgsql-general(at)postgreSQL(dot)org
Subject: Problem with getting the right order
Date: 1998-10-21 21:30:22
Message-ID: 362CE0FC320.AADEHENRIKP@edu.herningts.dk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a datbase that look like this:

vnr|cnr|enr| ip|dato
---+---+---+---------------+----------------------
1| 1| 17|195.192.136.223|1998-10-14 02:30:18+02
2| 1| 1|195.192.136.164|1998-10-14 02:33:03+02
5| 1| 13|195.192.136.173|1998-10-14 02:49:24+02
8| 1| 15|195.192.136.207|1998-10-14 02:49:27+02
9| 1| 16|195.192.136.211|1998-10-14 02:49:31+02
10| 1| 11|195.192.136.123|1998-10-14 02:49:44+02
11| 1| 15|195.192.136.162|1998-10-14 02:49:48+02
7| 1| 13|195.192.136.126|1998-10-14 02:49:50+02

Where vnr, cnr, enr are int fields, and ip, date are text. The database
is used for a votingsystem. vnr is the vote number, cnr is the
contestnumber and enr is the entrynumber.

When i do a :

./psql -c "select count(vnr),enr from votes where cnr=1 group by enr"
vote

to get the result from contest number 1 i get :

count|enr
-----+---
11| 1
1| 2
1| 3
4| 4
1| 5
1| 6
10| 8
....

This is almost what i want, execpt that i want the result to be ordered
by count, instead og enr. so that the entry, which got most votes is listed first

For example:

11| 1
10| 8
4| 4
1| 2
1| 3
1| 5
1| 6

hope someone outthere can help me :)

Henrik Pedersen
Demark

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Castillo 1998-10-22 04:02:13 CORBA and PostgreSQL
Previous Message Herouth Maoz 1998-10-21 17:01:42 Re: [GENERAL] datetime problems