sql - How do I Display one Row for the lowest number of a column? -


This question is complex so the examples will work best ... I have the following table on ODBC, SQL Server is not management

  NAME SEQNUM JOHN 2 JOHN 4 JOHN 7 MARY 12 MIKE 4 MIKE 9 PETER 7 PETER 12  

Therefore, I return a name with the lowest ranking I want to draw SEQNUM JOHN 2 MARY 12 MIKE 4 PETER 7

This data will not work with SELECT (MIN (SEQNUM)) . She gives a number I want to put the actual data into my dataset. Does anyone know how to do that? T2.name and t1.seqnum> T2.seqnum) is the WHERE t2.seqnum tap;


Reminds the comment:

If you simply use the name by group , then your selection list only name and the overall function MIN () . This is often the case that in fact you want the whole line where the minimum value per group is.

If you use the TOP solution (or LIMIT ) you use MySQL, PostgreSQL, SQLite), then you You can not get minimum for many groups based on the name , you can get a minimum for only one name . I read between the lines of OP questions and guessed that they want the whole line, that there are more columns (and always) than the tasks shown in the question, and the desired query results for many Give the name, not just one

* Connect to your TTA (Name of Selection, name by SET (Net) by YourTable Group), T2 Usage (name, seqnum);

However, this solution may not use the index to evaluate potentially connectivity, while I have the solution given.


Comments