Tuesday, July 03, 2007

Using DISTINCT in Select Statement

When you use DISTINCT in a Select statement, you are saying that you only want one row in the result set for each distinct set of values. The result set will not have any two rows that have the same values in every column.

Let's say in table SOP30300, you have the following data:
INV001 Items: ABC, DEF, GHI
INV002 Items: DEF, JKL, MNO
INV003 Items: MNO

Then you run this statement:
SELECT DISTINCT itemnmbr
FROM dbo.SOP30300

The result set should be:
ABC,DEF,GHI,JKL,MNO

3 comments:

Anonymous said...

using GROUP BY will produce the same result.

ex: SELECT itemnmbr
FROM dbo.SOP30300
group by itemnmbr

Mills
http://gp-dynamics.com

Anonymous said...

Nice dispatch and this enter helped me alot in my college assignement. Gratefulness you on your information.

Anonymous said...

Nice brief and this enter helped me alot in my college assignement. Gratefulness you as your information.

e-Commerce discount types

In the world of retail today every retailer is trying to find ways and be creative to attract online customers. To attract your attention an...