现有表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后没有返回查询结果
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后没有返回查询结果
where ordered_by='030302' and item_name = '头孢克肟片' and to_char(Billing_Date_time,'YYYY-MM-DD') between '2010-09-20' and '2010-10-20'
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');沒查詢到數據,可能是表中確實沒有相應的數據。
select * from inp_bill_detail where ordered_by='030302' and item_name = '头孢克肟片' and Billing_Date_time ...不是吧,兰州?貌似很简单的,没有结果返回不正常?是不是数据库中根本就没有符合条件的数据啊?
--写了下,不知道有没有结果:
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');
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')
没别的问题
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');