月份处理及SQL时间条件instr函数
YearCode:=yearof(Date);
MonthCode:=monthof(Date);
if MonthCode>9 then
FTime1:=inttostr(YearCode)+inttostr(MonthCode)
else
FTime1:=inttostr(YearCode)+'0'+inttostr(MonthCode);
FTime:= DateTimeToStr(Date); //
//FTime1:=formatdatetime('yyyymm',Date);
//FTime1:=leftstr(FTime,6);
TimeTemp:=formatdatetime('yyyy-mm',Date);
cds.Active:=false;
cds.CommandText:='select /*+index(a,TAB1_I)*/ max(a.id) as id from TAB1 a where '
+'INSTR(a.id,'''+FTime1+''', 1,1 )>0 and length(a.id)=11 and a.UPDATE_TIME between '
+' to_date('''+TimeTemp+'-01 00:00:00'',''yyyy-mm-dd hh24:mi:ss'') '
+' and to_date('''+FTime+''',''yyyy-mm-dd hh24:mi:ss'') ' ;
cds.Active:=true;
相关文档:
declare @id varchar(10)
declare @nm varchar(10)
declare @table as table(emp varchar(10),empname varchar(10))
declare CurEmp cursor for select top 6 empid,empname from employee
open CurEmp
fetch next from CurEmp into @id,@nm
While @@fetch_status=0
begin
insert @table(emp,e ......
2.根据Oracle 数据库scott 模式下的emp 表和dept 表,完成下列操作:
(1) 查询20号部门的所有员工信息;
(2) 查询所有工种为CLERK 的员工的员工号、员工名和部门号;
(3) 查询奖金COMM 高于工资SAL 的员工信息;
  ......
原文传送门:http://topic.csdn.net/u/20091010/14/FC7737C1-D60B-43F1-A8B5-A9EEF2DE4426.html
假如现在有两张表:
1.表stuinfo
sid sname subs
1 jack |1|2|
2 marry |1|4|
3 tom |3|
2.表subinfo
subid subname
1 physics
2 &n ......
题目1:
问题描述:
S (SNO,SNAME) 学生关系。SNO 为学号,SNAME 为姓名
C (CNO,CNAME,CTEACHER) 课程关系。CNO 为课程号,CNAME 为课程名,CTEACHER 为任课教师
SC(SNO,CNO,SCGRADE) 选课关系。SCGRADE 为成绩
1.(1)找出选修过“李明”老师讲授课程的所有学生姓名
--实现代 ......