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
I would like to get the row (only one) which has the minimun value of N_UM, in this case the row with id=10 (10 0).
我想获得具有最小值N_UM的行(仅一个),在这种情况下是id = 10(10 0)的行。
7 个解决方案
#1
15
Try this -
尝试这个 -
select top 1 * from table where N_UM = (select min(N_UM) from table);
#2
19
select * from TABLE_NAME order by COLUMN_NAME limit 1
#3
17
I'd try this:
我试试这个:
SELECT TOP 1 *
FROM TABLE1
ORDER BY N_UM
(using SQL Server)
(使用SQL Server)
#4
6
Use this sql query:
使用这个SQL查询:
select id,IDSLOT,N_UM from table where N_UM = (select min(N_UM) from table));
#5
3
Method 1:
方法1:
SELECT top 1 *
FROM table
WHERE N_UM = (SELECT min(N_UM) FROM table);
Method 2:
方法2:
SELECT *
FROM table
ORDER BY N_UM
LIMIT 1
A more general solution to this class of problem is as follows.
对这类问题的更一般的解决方案如下。
Method 3:
方法3:
SELECT *
FROM table
WHERE N_UM IN (SELECT MIN(N_UM) FROM table);
#6
1
Here is one approach
这是一种方法
Create table #t (
id int,
IDSLOT int,
N_UM int
)
insert into #t ( id, idslot, n_um )
VALUES (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)
select Top 1 *
from #t
Where N_UM = ( select MIN(n_um) from #t )
#7
0
select TOP 1 Col , COUNT(Col) as minCol from employee GROUP by Col
order by mindep asc
#1
15
Try this -
尝试这个 -
select top 1 * from table where N_UM = (select min(N_UM) from table);
#2
19
select * from TABLE_NAME order by COLUMN_NAME limit 1
#3
17
I'd try this:
我试试这个:
SELECT TOP 1 *
FROM TABLE1
ORDER BY N_UM
(using SQL Server)
(使用SQL Server)
#4
6
Use this sql query:
使用这个SQL查询:
select id,IDSLOT,N_UM from table where N_UM = (select min(N_UM) from table));
#5
3
Method 1:
方法1:
SELECT top 1 *
FROM table
WHERE N_UM = (SELECT min(N_UM) FROM table);
Method 2:
方法2:
SELECT *
FROM table
ORDER BY N_UM
LIMIT 1
A more general solution to this class of problem is as follows.
对这类问题的更一般的解决方案如下。
Method 3:
方法3:
SELECT *
FROM table
WHERE N_UM IN (SELECT MIN(N_UM) FROM table);
#6
1
Here is one approach
这是一种方法
Create table #t (
id int,
IDSLOT int,
N_UM int
)
insert into #t ( id, idslot, n_um )
VALUES (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)
select Top 1 *
from #t
Where N_UM = ( select MIN(n_um) from #t )
#7
0
select TOP 1 Col , COUNT(Col) as minCol from employee GROUP by Col
order by mindep asc