I want to check if a piece of data appears more than once in a particular column in my table using SQL. Here is my SQL code of what I have so far:
select * from AXDelNotesNoTracking where count(salesid) > 1
salesid
is the column I wish to check for, any help would be appreciated, thanks.
This question is related to
sql
How about:
select salesid from AXDelNotesNoTracking group by salesid having count(*) > 1;
try this:
select salesid,count (salesid) from AXDelNotesNoTracking group by salesid having count (salesid) >1
To expand on Solomon Rutzky's answer, if you are looking for a piece of data that shows up in a range (i.e. more than once but less than 5x), you can use
having count(*) > 1 and count(*) < 5
And you can use whatever qualifiers you desire in there - they don't have to match, it's all just included in the 'having' statement. https://webcheatsheet.com/sql/interactive_sql_tutorial/sql_having.php
Source: Stackoverflow.com