现有表inp_bill_detail结构如下
         patient_id char(10),
visit_id decimal(16, 0),
item_no decimal(16, 0),
item_class char(1),
item_name char(40),
item_code char(10),
amount decimal(16, 2),
units char(8),
ordered_by char(8),
performed_by char(8),
costs decimal(16, 2),
charges decimal(16, 2),
billing_date_time datetime,
operator_no char(4),
rcpt_no char(8),
st_date datetime,
settle_indicator char(1),
class_on_inp_rcpt char(1));
查询有几个要求ordered_by='030302'和item_name = '头孢克肟片'还有日期字段Billing_Date_time必须指定在2010-9-20到2010-10-20这期间,我组织的查询用了好几个and后没有返回查询结果

解决方案 »

  1.   

    select * from inp_bill_detail
    where ordered_by='030302' and item_name = '头孢克肟片' and to_char(Billing_Date_time,'YYYY-MM-DD') between '2010-09-20' and '2010-10-20'
      

  2.   

    select * 
    from inp_bill_detail
    where ordered_by='030302' 
    and item_name = '头孢克肟片'
    and Billing_Date_time between to_date('2010-09-20','yyyy-mm-dd') and to_date('2010-10-20','yyyy-mm-dd');沒查詢到數據,可能是表中確實沒有相應的數據。
      

  3.   


    select * from inp_bill_detail where ordered_by='030302' and item_name = '头孢克肟片' and Billing_Date_time ...不是吧,兰州?貌似很简单的,没有结果返回不正常?是不是数据库中根本就没有符合条件的数据啊?
      

  4.   


    --写了下,不知道有没有结果:
    select * from inp_bill_detail
    where ordered_by='030302' and item_name = '头孢克肟片' 
    and Billing_Date_time between to_date('2010-09-20','YYYY-MM-DD') and to_date('2010-10-20','YYYY-MM-DD');
      

  5.   

    select * from inp_bill_detail
    where trim(ordered_by)='030302' and trim(item_name) = '头孢克肟片' and Billing_Date_time between to_date('2010-09-20','YYYY-MM-DD') and to_date('2010-10-20','YYYY-MM-DD')
      

  6.   

    datetime类型那个注意类型的转换
    没别的问题
      

  7.   

    --把你的sql语句列出来
    select *  
    from inp_bill_detail
    where ordered_by='030302'  
    and item_name = '头孢克肟片'
    and Billing_Date_time 
        between to_date('2010-09-20','yyyy-mm-dd') 
        and to_date('2010-10-20','yyyy-mm-dd');
      

  8.   

    看似挺简单的,我也是这么查的甚至我怕没有这种药我把and item_name = '头孢克肟片'去掉了,也没有返回查询值.但数据库里面的确有这些数据.