Thread: query problem

query problem

From
"Gyan"
Date:
Greetings!
Kindly lemme know how do u sort a table on some field...please talk about the command that does it.
Thanx.
Gyan Ranjan

Re: query problem

From
will trillich
Date:
On Fri, Mar 23, 2001 at 02:21:24PM -0000, Gyan wrote:
> Greetings!  Kindly lemme know how do u sort a table on some
> field...please talk about the command that does it.  Thanx.

the sorting is done in the select command (see the docs under
'SELECT' for more detail):

    select p.fullname,e.salary,d.name as dept,d.supervisor
    from person p,employee e,department d
    where p.id=e.id and dept.id=e.dept
    ORDER BY dept,fullname

--
It is always hazardous to ask "Why?" in science, but it is often
interesting to do so just the same.
        -- Isaac Asimov, 'The Genetic Code'

will@serensoft.com
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Re: query problem

From
Einar Karttunen
Date:
On Fri, 23 Mar 2001, Gyan wrote:

> Greetings!
> Kindly lemme know how do u sort a table on some field...please talk about the command that does it.
> Thanx.
> Gyan Ranjan
>
using the ORDER BY clause in a query. eg
SELECT col1,col2,col3 FROM tablename ORDER BY col1;
You can get info on how to use sql from the postgresql documentation
(http://www.postgresql.org), but best would be if you'd just read a
book about sql.

- Einar Karttunen