sql server - Determining if one row's column equals another row's column -
sql server - Determining if one row's column equals another row's column -
hello table this:
id | name | description | location | effec_dte ---------------------------------------------- 1 | serv | ohcod01 | nyny | 2014-1-1 2 | serv | ohcod01 | cala | 2014-1-1 3 | serv | ohcoa11 | scco | 2014-5-1 4 | serv | ohcoa11 | scco | 2014-5-1 ...
in illustration there 2 applications, 1 hosted in new york , la other hosted in columbia. want find each application , check first , sec row determine if in same city or hosted in 2 different cities.
is there way this?
thanks!
edit:
select name table (//logic find names exist in 2 locations)
belong 2 or more different cities
with cte ( select *, row_number() over(partition location order id ) row mytable ) cte.row>1
belong 1 cities
with cte ( select *, row_number() over(partition location order id ) row mytable ) cte.row=1
sql-server
Comments
Post a Comment