Sidebar

How can I check a column in a database to see if it contains unique data.

0 votes
291 views
asked Jul 9, 2013 by rich-c-2789 (16,180 points)

1 Answer

0 votes
 
Best answer
Here is one way to check.  In this case, if the following query returns any results, we know that the medicationDescription contains duplicates

SELECT medicationDescription, COUNT(medicationDescription) FROM Meds GROUP BY medicationDescription HAVING COUNT(medicationDescription) > 1
answered Jul 9, 2013 by rich-c-2789 (16,180 points)
selected Dec 17, 2013 by ron-s-6919
...