Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Looking for Identical IDs under different Types

Author  Topic 

Velnias
Yak Posting Veteran

58 Posts

Posted - 2009-07-28 : 07:55:25
PropertyId TYPE
550 CORRECT
550 CORRECT
550 WRONG
550 WRONG
552 Correct

Im looking for a query that will return all ids which are used multiple times for identical identifier such as here TYPE = 'CORRECT'
since it came up twice for propertyId = 550

That it returns 550 twice

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-07-28 : 07:58:26
What version of SQL are you using?
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-07-28 : 08:03:18
Can't you just do this?

SELECT
[propertyId]
, [TYPE]
, COUNT([propertyId]) AS [Times Repeated]
FROM
<<yourtable>>
GROUP BY
[propertyId]
, [TYPE]
HAVING
COUNT([propertyId]) > 1



Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -