如何在SQL中加入后删除重复项

时间:2016-05-11 20:20:47

标签: join sql-server-2012 duplicates

非常新对SQL - 善良!我试图从此连接中删除重复项。我下一步要做什么?!我知道使用df <- structure(list(pickup_datetime = structure(c(1473923636, 1474161169, 1474252913, 1474259376, 1474419723, 1473903309), class = c("POSIXct", "POSIXt")), trip_distance = c(8.1, 10.6, 15.9, 8.9, 11.5, 9.6 ), pickup = c("40.77419,-73.872608", "40.7737,-73.870721", "40.773761,-73.87086", "40.773776,-73.870908", "40.774161,-73.87302", "40.774135,-73.8749" ), dropoff = c("40.78055,-73.955042", "40.757007,-73.971953", "40.707277,-74.007301", "40.770568,-73.95468", "40.758284,-73.986621", "40.758691,-73.961359")), class = "data.frame", .Names = c("pickup_datetime", "trip_distance", "pickup", "dropoff"), row.names = c(NA, -6L)) 但不确定在哪里......

select distinct

1 个答案:

答案 0 :(得分:0)

使用可以使用DISTINCT但请注意,它与SELECT

中的所有列截然不同
SELECT DISTINCT
     ac.[dc_id] 
    ,center_name
    ,ecec 
    ,inspec_date
    ,facility_type
    ,sitetype
    ,new_sitetype
FROM usrbesp.wrk_city_active_sites ac
inner JOIN usrbesp.t_gdc_activity a
ON ac.dc_id = a.dc_id  
order by dc_id