oracle数据库product表里面存储了一些数据,product表里有一字段saledate,存储的类似于2008-5-22格式的数据,我现在只想用查2009-09月的数据,应该怎么查?用select name,price,saleCount,to_char(saledate,'yyyy-mm-dd') as saleDate  from product where  saleDate like '%2009-09%'  order by saleDate 不行,网上有一答案如下:
select * from news where
substring(Convert(char(10),date,112),1,8)='20090112'按日查
substring(Convert(char(10),date,112),1,8)='20090112'
按月查
substring(Convert(char(10),date,112),1,6)='200901'
按年查
substring(Convert(char(10),date,112),1,4)='2009' 试了一下也不行。谁能帮帮我

解决方案 »

  1.   

    select name,price,saleCount,to_char(saledate,'yyyy-mm-dd') as saleDate  from product where to_char(saledate,'yyyy-mm')='2009-09'  order by saleDate 
      

  2.   

    select * from product
    where to_char(saledate,'yyyymm')=='200909'
      

  3.   

    你查到的那些是SQL SERVER的语法。
      

  4.   

    如果saledate类型是date类型,那上面的就可以,如果是字符串类型
    select name,price,saleCount,saledate from product where substr(saledate,1,7)='2009-09'  order by saleDate
      

  5.   

    select * from product
    where to_char(saledate,'yyyymm')=='200909'