Wednesday, September 9, 2009

Working with Duplicate Rows in SQL

Duplicate Rows :
  • The default display of queries is all rows, including duplicate rows
  • postgres=# select deptno from emp;
    deptno
    --------
    20
    30
    30
    20
    30
    30
    10
    20
    10
    30
    20
    30
    20
    10
    (14 rows)
Selecting Unique Rows (Deleting Duplicates) :
  • postgres=# select distinct deptno from emp;
deptno
--------
10
20
30
(3 rows)

No comments:

Post a Comment

Followers