SELECT distinct loc.name,
loc.imageurl,
tu.userid,
tu.fname,
(SELECT TOP(1) [time]
FROM tblcheckin
WHERE userid = tf.followerid and flag ='C'
ORDER BY [time] DESC) AS [time]
, CONVERT(DECIMAL(16, 2), (dbo.DistanceBetween( loc.latitude,loc.longitude,22.302647,73.190144))) as Distance
FROM tbl_follower tf
INNER JOIN tbluser tu
ON tf.followerid = tu.userid
LEFT OUTER JOIN tblgetlocation loc
ON loc.venueid = (SELECT TOP(1) locationid
FROM tblcheckin
WHERE userid = tf.followerid and flag ='C'
ORDER BY [time] DESC)
where tf.userid = 57 and tf.flag='YES'
http://tempuri.org/tempuri.html
Here is the output of my above query i have applied distinct but till the data are duplicated because of imageurl column.. so how can i remove duplicated record from result using userid. if userid repeated then delete record.
In my out put you can see,that the record with all data depends on userid, but i want to delete the record repeated with same userid if they are more then 1 then delete record of same userid having imageurl with 'ss1.4sql.net...'