SQL DISTINCT.

DISTINCT in the SELECT Statement

  • DISTINCT is used for eliminating duplicate rows.
    DISTINCT included within the SELECT Statement Syntax:
    SELECT [ALL | DISTINCT] select_list
      FROM table/view_list
      [WHERE search_conditions]
      [ORDER BY order_by_list ]
  • DISTINCT works on columns value combinations from select_list.
    Example:
    MySQL, Oracle, SQL server, PostgreSQL:
    select DISTINCT ISBN_no "ISBN"
      from order_books
      where Isbn_no like '%8'
      OR Isbn_no like '0%'
      AND item_qty*PRICE < 100
      order by ISBN_no DESC;
    The result should be:
    ISBN
    0764579088
    0764557599
    0672325764
    0471777781
    0201703092
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.