• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

DISTINCT

You can use the DISTINCT command to remove duplicated records. The following query, for example, lists all articles that were sold in January 2000. Because articles in this time period were, of course, sold several times, the DISTINCT command is used to output each article number with its name only once.

SELECT DISTINCT 
	TblProducts.ProductNr, 
	tblProducts.Description
FROM dbo.tblProducts INNER JOIN dbo.tblProductSales 
	ON dbo.tblProducts.ProductNr = dbo.tblProductSales.ProductNr
WHERE 
	(dbo.tblProductSales.Date BETWEEN 
 	CONVERT(DATETIME, '2000-01-01 00:00:00', 102) AND 
 	CONVERT(DATETIME, '2000-01-31 00:00:00', 102))


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint