Friday, September 18, 2009

Sorting retrieved rows in postgresql

Using the ORDER BY Clause :
  • Sort retrieved rows with the ORDER BY clause
    • ASC: ascending order, default
    • DESC: descending order
  • The ORDER BY clause comes last in the SELECT statement
  • SELECT ename, job, deptno, hiredate FROM emp ORDER BY hiredate ;
Sorting in descending order :
  • SELECT ename, job, deptno, hiredate FROM emp ORDER BY hiredate DESC ;

No comments:

Post a Comment

Followers