用oracle的话,查询语句该怎么写?
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/14 05:17:30
用oracle的话,查询语句该怎么写?
表中相关的字段有,beginDate,endDate,interest_rate三个,
起始时间至结束时间这一时间段内,对应一个值,前两个字段是char(8)型的,
对应日期的八个数字'yyyymmdd' 如:
id begin_date end_date interest_rate
----------- ---------- -------- ---------------------------------------
1 20130101 20130104 5.00000000
2 20130105 20130110 3.00000000
3 20130111 20130113 6.00000000
4 20130114 20130120 2.00000000
5 20130121 20130128 9.00000000
6 20130129 20130220 4.00000000
假设给定一个起始日期和结束日期,我需要查询这之间对应的每一天的interest_rate,
比如查询20130103到20130115,每天对应的值,查询结果如:
date_01 INTEREST_RATE
--------------------------------- -----------------------------
2013-01-03 00:00:00.000 5.00000000
2013-01-04 00:00:00.000 5.00000000
2013-01-05 00:00:00.000 3.00000000
2013-01-06 00:00:00.000 3.00000000
2013-01-07 00:00:00.000 3.00000000
2013-01-08 00:00:00.000 3.00000000
2013-01-09 00:00:00.000 3.00000000
2013-01-10 00:00:00.000 3.00000000
2013-01-11 00:00:00.000 6.00000000
2013-01-12 00:00:00.000 6.00000000
2013-01-13 00:00:00.000 6.00000000
2013-01-14 00:00:00.000 2.00000000
2013-01-15 00:00:00.000 2.00000000
Oracle 应该怎么写查询语句,
表中相关的字段有,beginDate,endDate,interest_rate三个,
起始时间至结束时间这一时间段内,对应一个值,前两个字段是char(8)型的,
对应日期的八个数字'yyyymmdd' 如:
id begin_date end_date interest_rate
----------- ---------- -------- ---------------------------------------
1 20130101 20130104 5.00000000
2 20130105 20130110 3.00000000
3 20130111 20130113 6.00000000
4 20130114 20130120 2.00000000
5 20130121 20130128 9.00000000
6 20130129 20130220 4.00000000
假设给定一个起始日期和结束日期,我需要查询这之间对应的每一天的interest_rate,
比如查询20130103到20130115,每天对应的值,查询结果如:
date_01 INTEREST_RATE
--------------------------------- -----------------------------
2013-01-03 00:00:00.000 5.00000000
2013-01-04 00:00:00.000 5.00000000
2013-01-05 00:00:00.000 3.00000000
2013-01-06 00:00:00.000 3.00000000
2013-01-07 00:00:00.000 3.00000000
2013-01-08 00:00:00.000 3.00000000
2013-01-09 00:00:00.000 3.00000000
2013-01-10 00:00:00.000 3.00000000
2013-01-11 00:00:00.000 6.00000000
2013-01-12 00:00:00.000 6.00000000
2013-01-13 00:00:00.000 6.00000000
2013-01-14 00:00:00.000 2.00000000
2013-01-15 00:00:00.000 2.00000000
Oracle 应该怎么写查询语句,
创建测试表
create table test
(id int,
begin_date char(8),
end_date char(8),
interest_rate int);
insert into test values (1,'20130101','20130104',5);
insert into test values (2,'20130105','20130110',3);
insert into test values (3,'20130111','20130113',6);
insert into test values (4,'20130114','20130120',2);
执行
with t as
(select to_char(to_date('20130103','yyyymmdd')+rownum-1,'yyyymmdd') as tdate from dual connect by rownum<50)
select t.tdate,test.interest_rate from t,test
where t.tdate between '20130103' and '20130115' and t.tdate between test.begin_date and test.end_date
结果
create table test
(id int,
begin_date char(8),
end_date char(8),
interest_rate int);
insert into test values (1,'20130101','20130104',5);
insert into test values (2,'20130105','20130110',3);
insert into test values (3,'20130111','20130113',6);
insert into test values (4,'20130114','20130120',2);
执行
with t as
(select to_char(to_date('20130103','yyyymmdd')+rownum-1,'yyyymmdd') as tdate from dual connect by rownum<50)
select t.tdate,test.interest_rate from t,test
where t.tdate between '20130103' and '20130115' and t.tdate between test.begin_date and test.end_date
结果
用oracle的话,查询语句该怎么写?
oracle 语句 查询优化
请教这样查询语句该怎么写.
oracle语句查询 or和and
oracle查询一个表,select * from a 所有的字段都是浮点型,想保留3个小数,怎么写语句?
oracle列求和?查询结果为:600ml+2U.语句怎么写,假设这是test表UTIT值为ml或者U.考虑有无ml,U
请问下面得查询语句怎么写
求单表查询的hql语句怎么写
Oracle查询数据怎么按照甲乙丙丁排序?
oracle 查询优化
oracle数据库 我想在查询数字时给数字后两位前面加上小数点(原数字位数不确定),怎么写查询sql?
oracle数据库有A、B两列,B列字段中包含A列字段,现在想把B列字段中的A字段删除掉,该怎么写语句?