Sql 如何在SYBASE中使用小日期拾取记录

Sql 如何在SYBASE中使用小日期拾取记录,sql,tsql,sybase,Sql,Tsql,Sybase,如何在SYBASE中使用小日期拾取记录 我使用以下查询 select count(id) as total, convert(date, my_dte, 101) as new_dte from my_table where convert(date, my_dte, 101) between '05/01/2014' and '05/31/2014' group by convert(date, my_dte, 101) order by convert(date, my

如何在SYBASE中使用小日期拾取记录

我使用以下查询

select count(id) as total, 
       convert(date, my_dte, 101) as new_dte
from   my_table
where  convert(date, my_dte, 101) between '05/01/2014' and '05/31/2014'
group by convert(date, my_dte, 101)
order by convert(date, my_dte, 101)
下面是这个查询的输出

**total        new_dte**
73             05/02/2014
14             05/06/2014
90             05/19/2014
36             05/21/2014
我只想取最小的日期记录。我正在使用这个查询

select max_rec.total
from 
(
select count(id) as total, 
       convert(date, my_dte, 101) as new_dte,
       ROW_NUMBER () OVER(PARTITION BY total ORDER BY new_date DESC ) as rn    
from   my_table
where  convert(date, my_dte, 101) between '05/01/2014' and '05/31/2014'
group by convert(date, my_dte, 101)
order by convert(date, my_dte, 101)
) max_rec
where max_rec.rn = 1;
但这不起作用,它给我的错误超过

期望输出:

任何帮助都将受到感谢。

您能不能

将原始查询包装为子查询

创建另一个子查询以返回最小日期值


对两个子查询执行内部联接,以从原始查询中获取与所需日期匹配的记录

没有人知道如何提取最小的日期记录。
**total        new_dte**
73             05/02/2014