സ്ത്രീകള്‍ എങ്ങിനെ വസ്ത്രം ധരിക്കണം എന്ന് പുരുഷന്‍ നിഷ്ക്കര്‍ഷിക്കുന്നത് ശരിയോ? അല്ലെങ്കില്‍ തിരിച്ചും?

Sunday, April 22, 2012

SQL: Query to find Duplicate Rows in a Table

If you would like to list duplicate rows with the count for a table, the following query would be helpful.

Query: Duplicate Rows

SELECT Column1,Column2,Column3,Count(*)
FROM dbo.TableName
GROUP BY Column1,Column2,Column3
HAVING ( COUNT(*) > 1 )

And there are scenarios where we need to find the combination of Columns in a table occurred only once. In such case the following query could be used.

Query: Unique combination of columns

SELECT Column1,Column2,Column3,Count(*)
FROM dbo.TableName
GROUP BY Column1,Column2,Column3
HAVING ( COUNT(*) = 1 )

Hope it helps.
Source : http://sapost.blogspot.in/

No comments:

Post a Comment

Hmmmmm... what are you thinking? Do not forget to comment,It helps us to improve this blog and help us to make better. on