query problem

Started by Gyanabout 25 years ago3 messagesgeneral
Jump to latest
#1Gyan
gyan@noida.hcltech.com

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

#2will trillich
will@serensoft.com
In reply to: Gyan (#1)
Re: query problem

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!

#3Einar Karttunen
ekarttun@cs.Helsinki.FI
In reply to: Gyan (#1)
Re: query problem

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