SQL Query, Pull Device listing with 1st DN

Version 1
    This document was generated from CDN thread

    Created by: Jeff Garner on 18-11-2009 07:26:51 PM
    Does any one have a good SQL query to pull a listing of devices with the first DN,  One query I have produces multiple listing of the same device for each DN, Ive tried using the DISTINCT command with lo luck on this query
    SELECT FIRST 5 D.Name as name, D.description as desc, NP.dnorpattern as dn FROM NumPlan NP , DeviceNumPlanMap DNPMap, Device D where UPPER(D.Name) like 'SEP%' AND DNPMap.fkNumPlan = NP.pkid AND D.pkid = DNPMap.fkDevice;
    I know there has to be a better way with a JOIN perhaps?

    Subject: RE: SQL Query, Pull Device listing with 1st DN
    Replied by: David Staudt on 18-11-2009 08:43:23 PM
    If you are looking to return only the top line, try  adding 'devicenumplanmap.numplanindex=1' to the WHERE clause