select - SQL query: only one dataset per specific attribut -


I want to get only one dataset from the database for each specific attribute (column value). Example: You have a table like this: Restaurant District Latitude Latitude -------------------------- - ------------ Deli meals 1 80.456 -56.89 Perseus 1 80.879 -56.00 Artica 2 67.7080 -69.8 9 Tie 2 67.00 -69.00 Petra 3 89.00 -78.89

And you want only one instance for every district such as:

  Daily meal 1 80.456 -56.8 9 Articon 2 67.7080-69.8 9 Peter 3 89.00 -78.89   

How do I achieve this goal? Generally I used to be in the group of the district only, but then I remove other features. Thanks for all the replies !!

There are several ways to solve it, using one subquery for each district separately A record gets that since you have not mentioned your RDBMS which you are using, it will work on almost all RDBMS.

  SELECT a. * An Inner Join from the table (Select District, Max (Longitude) max_val FROM, table name GROUP by district) b on a.district = b.district and a.longitude = max_val   
  • Output

      one ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ??? ? One ???? One ???? One ???? One ???? One ?? | Â ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ?? | Â ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ?? | Â ???? One ???? One? ??? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? a???? A restaurant District LONGITUDE One ???? Latitude one ???? a?? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ?? One One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ?? One One ???? One ???? One ???? One ???? One ???? One? ??? One ???? One ???? One ???? One ???? One ?? One One ???? One ???? One ???? One ?? Line Line Line Line Line Line Line Line Line Perseus one ???? 1 A 80.879 A-56.00 A A Articulate one ???? 2 a 67.708 one-69.8 9 an A ???? Peter said 3 a 89.00 a-78.8 9 one a ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ?? © one ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ???? One ?? © one ???? One ???? One ???? One ???? One ???? One? ??? One ???? One ???? One ???? One ???? One ???? One ?? © one ???? One ???? One ???? One ?? ?? One ???? One ???? One ???? One ???? One ???? One ???? One ???? As an archive list with   

    UPDATE 1

      (Selection Center, District, Longitude, Latitude, ROW_NUMBER () Select the RNR from the table name, by the name of the district, district, longitude, latitude where RN = 1   
    • < / Ul>

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -