1:如何抽取距离当前时间,前5天的记录? 2:如何得到记录中不同的值出现的次数?3:如何得到一个字段中出现的不同值?例如有一个字段有5行,分别是:x
y
y
x
z我希望得到的结果是x,y,z! 也就是想知道这个字段中出现的都是哪些值

解决方案 »

  1.   

    1. 用日期函数,可以搜下sql2000的帮助文件
    2.  用count函数应该需要用group分组
    3.  选择的时候用DISTINCT 排除重值
      

  2.   

    第一个问题,我想这样应该可以实现,LZ试试
    select top 5 * from  [table] where 日期<'2006-07-02' order by 日期 desc
      

  3.   

    '2006-07-02' 如何替换为当前时间?  用GetDate()??
      

  4.   

    1.sql函数GetDate和DayAdd
    2.distinct或group by和count
    2.distinct
      

  5.   

    1.datediff(dd,str_dt,getdate())<5
    2.select count(字段) from table group by 字段
    3.select DISTINCT 字段……