Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select Query for duplicate values

Using SQL Server 2000

I Want to Check the colum value whether it is same or not

Table1

ID Value

001 1000
002 1000
003 5000

From the above table, nothing display in the output, because values are differenct for each id.

If the values are same for all the id, then display otherwise nothing display.

How to make a select query.

Need Query Help

like image 262
Gopal Avatar asked Feb 14 '26 21:02

Gopal


1 Answers

This code will look at the number of duplicate Values for an ID, and return:

ID, Duplicate Value, number of times this value exists in the table.

SELECT Id, Value
   , COUNT(1) AS occurances
FROM Table1
GROUP BY ID, VALUE
HAVING COUNT(1) > 1
like image 174
Adam Wenger Avatar answered Feb 17 '26 11:02

Adam Wenger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!