请教 日期的排列顺序!
请教 日期的排列顺序!
如:
BILLDATE
2007-07-01
2007-07-05
2007-07-03
2007-07-04
2007-07-30
2007-07-29
1\求转换为如下格式
ITEMNO BILLDATE
1 2007-07-01
2 2007-07-03
3 2007-07-04
4 2007-07-05
5 2007-07-29
6 2007-07-30
目的:查找出本月本批生产 第X次领料日期!
2\如ITEMNO 列不增加如何查找第2次领料日期或第3次领料日期???
------解决方案--------------------declare @n int --第幾次
select top 1 A.* from table1 A where A.BILLDATE not in (select top @n B.BILLDATE from table1 B order by B.BILLDATE) order by A.BILLDATE
------解决方案--------------------declare @n int --第幾次
select top 1 A.* from table1 A where A.BILLDATE not in (select top @n-1 B.BILLDATE from table1 B order by B.BILLDATE) order by A.BILLDATE