在查询sql server的地方使用min值

时间:2014-08-19 02:34:15

标签: sql-server

我在表格中有这样的数据:

==============================================================================================
               id                                      idPaper                 Code Sequential
==============================================================================================
1A506D10-9306-495A-9E4E-7081E3D3ACDB    F4CFE90D-0921-4FB7-A236-5420B0892379    0036    2
3DB0FEBF-FBDF-4768-B36A-83AF4FB53E4B    F4CFE90D-0921-4FB7-A236-5420B0892379    0035    1

我想要这样的显示数据:

==============================================================================================
               id                                      idPaper                 Code Sequential
==============================================================================================
3DB0FEBF-FBDF-4768-B36A-83AF4FB53E4B    F4CFE90D-0921-4FB7-A236-5420B0892379    0035    1
1A506D10-9306-495A-9E4E-7081E3D3ACDB    F4CFE90D-0921-4FB7-A236-5420B0892379    0036    2

我运行我的查询:

select * 
from tablename 
where idPaper = 'F4CFE90D-0921-4FB7-A236-5420B0892379' 
  and min(sequential)

但它不起作用。请帮帮我......

...谢谢

2 个答案:

答案 0 :(得分:1)

我认为您只想对数据进行排序。也许你只是想要:

select * 
rom tablename
where idPaper='F4CFE90D-0921-4FB7-A236-5420B0892379' 
order by sequential;

答案 1 :(得分:0)

您可以使用order by

select *
from tablename 
where idPaper='F4CFE90D-0921-4FB7-A236-5420B0892379'
order by sequential