已知系统时间是2009年8月10日,下面是表m: 
              
              产品编号    安装时间        过保时间 
                1      2006-01-01    2008-01-01 
                2      2006-08-08    2009-08-08 
                3      2007-09-09    2011-09-09 各位:怎么求过了保质期的产品编号????sql语句怎么写啊??!!!!!
我分数不多了,就2分意思下吧~~

解决方案 »

  1.   

    select *
    from tb
    where 过保时间<'2009-08-10'
      

  2.   

    select * from 表M where 过保时间<='2009-08-10'
      

  3.   

    select 产品编号 from tb where datediff(day,getdate(),过保时间)<0
      

  4.   

    select 产品编号 from tb where 过保时间 <'2009-08-10'
      

  5.   

    ----------------------------------------------------------------
    -- Author :fredrickhu(小F 向高手学习)
    -- Date   :2009-08-12 10:32:43
    ----------------------------------------------------------------
    --> 测试数据:[tb]
    if object_id('[tb]') is not null drop table [tb]
    go
    create table [tb]([产品编号] int,[安装时间] datetime,[过保时间] datetime)
    insert [tb]
    select 1,'2006-01-01','2008-01-01' union all
    select 2,'2006-08-08','2009-08-08' union all
    select 3,'2007-09-09','2011-09-09'
    --------------开始查询--------------------------select * from [tb] where 过保时间<'2009-08-10'
    ----------------结果----------------------------
    /*产品编号        安装时间                                                   过保时间                                                   
    ----------- ------------------------------------------------------ ------------------------------------------------------ 
    1           2006-01-01 00:00:00.000                                2008-01-01 00:00:00.000
    2           2006-08-08 00:00:00.000                                2009-08-08 00:00:00.000(所影响的行数为 2 行)*/