如何找到同一城市和相同的工资记录

时间:2016-02-22 12:36:18

标签: sql sql-server

我希望通过使用临时表

找到多个相同的城市和相同的工资记录

1 个答案:

答案 0 :(得分:0)

declare @t table
    (
     City nvarchar(20),
     Salary decimal(9, 2)
    )

insert  into @t
        (City, Salary)
values  (N'New York', 65000),
        (N'London', 68000),
        (N'Sydney', 59000),
        (N'Sydney', 59000),
        (N'Tokyo', 66000)

select  *
from    @t as t
group by t.City,
        t.Salary
having  count(1) > 1