Duplicated id
for pairs name
and city
:
select s.id, t.*
from [stuff] s
join (
select name, city, count(*) as qty
from [stuff]
group by name, city
having count(*) > 1
) t on s.name = t.name and s.city = t.city
More Related Contents:
- CROSS JOIN vs INNER JOIN in SQL
- Can I Comma Delimit Multiple Rows Into One Column? [duplicate]
- Split function equivalent in T-SQL?
- Querying data by joining two tables in two database on different servers
- Is having an ‘OR’ in an INNER JOIN condition a bad idea?
- Where value in column containing comma delimited values
- How to find all connected subgraphs of an undirected graph
- How to use table variable in a dynamic sql statement?
- SQL query to split column data into rows
- Bulk DELETE on SQL Server 2008 (Is there anything like Bulk Copy (bcp) for delete data?)
- Create Trigger to log SQL that affected table?
- Split values over multiple rows [duplicate]
- sql varchar(max) vs varchar(fix)
- How do I prevent a database trigger from recursing?
- SQL Server: should I use information_schema tables over sys tables?
- store arabic in SQL database
- Convert Date format into DD/MMM/YYYY format in SQL Server
- Converting Select results into Insert script – SQL Server
- TSQL – How to use GO inside of a BEGIN .. END block?
- How to combine results of two queries into a single dataset
- Executing SQL Server Agent Job from a stored procedure and returning job result
- SQL Server SELECT INTO @variable?
- How do I change db schema to dbo
- How to subtract 30 days from the current date using SQL Server
- Count records for every month in a year
- SQL Server: +(unary) operator on non-numeric Strings
- Use one CTE many times
- How to Select Every Row Where Column Value is NOT Distinct
- How to do a case sensitive GROUP BY?
- How to automatically generate unique id in SQL like UID12345678?