数据库中没有设置起启时间,只有从所有时间记录中算中总的天数,
以下是我的sql语句,大家给看看运行效率如何,怎么优化一下!!
SELECT TOP 1 DATEDIFF(d,
(SELECT TOP 1 stime
FROM online
ORDER BY id ASC),
(SELECT TOP 1 stime
FROM online
ORDER BY id DESC)) AS 天数
FROM online
要是在ASP里用可以这样
sql="SELECT TOP 1 stime FROM online ORDER BY id ASC"
rs.open sql,conn
d1=rs(0)
rs.close
sql="SELECT TOP 1 stime FROM online ORDER BY id DESC"
rs.open sql,conn
d2=rs(0)
rs.close