Author Topic: SQL DISTINCT  (Read 158 times)

0 Members and 1 Guest are viewing this topic.

Offline arpee

  • EquiBerks
  • Jr. Member
  • *
  • Posts: 80
  • Karma: +1/-0
    • View Profile
SQL DISTINCT
« on: October 01, 2008, 02:31:56 AM »
The SELECT keyword allows us to grab all information from a column (or columns) on a table. This, of course, necessarily mean that there will be redundancies. What if we only want to select each DISTINCT element? This is easy to accomplish in SQL. All we need to do is to add DISTINCT after SELECT. The syntax is as follows:

Code: [Select]
SELECT DISTINCT "column_name"
FROM "table_name"

For example, to select all distinct stores in Table Store_Information,

table:[table=Headline]
store_name Sales Date
Los Angeles $1500 Jan-05-1999
San Diego $250 Jan-07-1999
Los Angeles $300 Jan-08-1999
Boston $700 Jan-08-1999[/table]



[postit=Headline:1iug6ule]we key in,[/postit:1iug6ule]


SELECT DISTINCT store_name FROM Store_Information

Result:

Code: [Select]
store_name
Los Angeles
San Diego
Boston

Techronnati | where technology never sleeps

SQL DISTINCT
« on: October 01, 2008, 02:31:56 AM »

Mountain View

 

Related Topics

  Subject / Started by Replies Last post
0 Replies
140 Views
Last post October 01, 2008, 01:56:05 AM
by arpee
0 Replies
137 Views
Last post October 01, 2008, 02:02:35 AM
by arpee
0 Replies
124 Views
Last post October 06, 2008, 04:52:13 AM
by GBTalk
1 Replies
116 Views
Last post July 22, 2016, 03:58:24 AM
by JusticeLeague
0 Replies
17 Views
Last post August 23, 2017, 10:59:22 AM
by GBTalk

Posting Disclaimer: Any individual may post a message in this forum and may do so anonymously. Therefore, the sole author is exclusively and entirely responsible for all opinions in that message. They do not represent the official opinions of Techronnati, its administrators or moderators or the Techronnati Management. Techronnati is merely acting as an impartial conduit for constitutionally protected free speech and is not responsible and will not be held liable for the content of such messages. All images and service logos are trademarks of their respective owners.