row with minimum value of a column

前端 未结 7 1040
孤独总比滥情好
孤独总比滥情好 2021-01-01 11:25

Having this selection:

id IDSLOT  N_UM
------------------------
1  1  6
2  6  2
3  2  1
4  4  1
5  5  1
6  8  1
7  3  1
8  7  1
9  9  1
10  10  0


        
相关标签:
7条回答
  • 2021-01-01 11:36

    Use this sql query:

    select id,IDSLOT,N_UM from table where N_UM = (select min(N_UM) from table));
    
    0 讨论(0)
  • 2021-01-01 11:37
    select TOP 1  Col , COUNT(Col) as minCol from employee GROUP by Col
    order by mindep  asc
    
    0 讨论(0)
  • 2021-01-01 11:44

    I'd try this:

    SELECT TOP 1 *
    FROM TABLE1
    ORDER BY N_UM
    

    (using SQL Server)

    0 讨论(0)
  • 2021-01-01 11:45

    Method 1:

    SELECT top 1 * 
    FROM table 
    WHERE N_UM = (SELECT min(N_UM) FROM table);
    

    Method 2:

    SELECT * 
    FROM table 
    ORDER BY N_UM 
    LIMIT 1
    

    A more general solution to this class of problem is as follows.

    Method 3:

    SELECT *
    FROM table 
    WHERE N_UM IN (SELECT MIN(N_UM) FROM table);
    
    0 讨论(0)
  • 2021-01-01 11:50
    select * from TABLE_NAME order by COLUMN_NAME limit 1
    
    0 讨论(0)
  • 2021-01-01 11:57

    Try this -

     select top 1 * from table where N_UM = (select min(N_UM) from table);
    
    0 讨论(0)
提交回复
热议问题