troubleshooting Question

Select distinct

Avatar of Aleks
AleksFlag for United States of America asked on
Web Languages and StandardsMicrosoft SQL ServerWeb DevelopmentASPSQL
25 Comments3 Solutions257 ViewsLast Modified:
I have the query below, which may return identical records other than the 'logid' being different.

I want to display only those records which are different, in other words, records that are identical OTHER than the 'logid' which will be different since its an incremental ID.  
The problem is if I remove the logid then I get the records I need, but then I can't order by logid  :$  which I need to have the most recent record at the top.
Is there a way around this ?

        a.logid ,
        a.firmid ,
        a.userid ,
        a.fileid ,
        a.filetype ,
        a.searchdate ,
        b.FirstNm ,
        b.LastNm ,
        b.Dob ,
FROM    dbo.LogSearches a
        INNER JOIN Users AS b ON b.UserId = a.fileid
WHERE   a.firmid = 2
        AND a.userid = 1713
        AND a.filetype = 'contact'
ORDER BY a.logid DESC;
Join our community to see this answer!
Unlock 3 Answers and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros