oracle sql 时间间隔计算
计算间隔时间:
select f_date,f_cstime,f_cetime, (((SYSDATE- TO_DATE(f_date||f_cstime,'YYYYMMDDHH24MISS')) * 86400000)-((SYSDATE- TO_DATE(f_date||f_cetime,'YYYYMMDDHH24MISS')) * 86400000))/1000 CURRENT_MILLI from ycsq_t_hauthlog where f_cstime<>'999999'
将字符串转换成日期类:SYSDATE- TO_DATE(f_date||f_cstime,'YYYYMMDDHH24MISS'),
SYSDATE- TO_DATE(f_date||f_cstime,'YYYYMMDDHH24MISS')*86400000 转换成毫秒
相关文档:
/********************************
功能:获取表的空间分布情况
**********************************/
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablespaceinfo]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
create table tablespaceinfo   ......
create function dbo.F_Get_No
(
@No varchar(100)
)
RETURNS bigint
AS
BEGIN
WHILE PATINDEX('%[^0-9]%',@No)>0
BEGIN
SET @No=STUFF(@No,PATINDEX('%[^0-9]%',@No),1,'') --删掉一个非数字的字符,循环结束,剩余的为数字部分
END
RETURN CONVERT(bigint,@No ......
列出TableA中有的而TableB中没有, 以及B中有而A中没有的记录:
其中两个表的结构相同,选择的Key可以多个
Select Key from
( select * from TableA
Union select * from TableB
)
group by Key
having count(Key)=1
列出TableA中有的而TableB中没有的记录:
Select Key from
( (select * from TableA
Un ......
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询“”课程比“”课程成绩高的所有学生的学号;
SELECT a.S# from (SELECT s#,score from SC WHERE C#='001') a,
(SELECT s#,score fr ......
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE proc pGetInsertSQL (@TableName varchar(256))
as
begin
set nocount on
declare @sqlstr varchar(4000)
declare @sqlstr1 varchar(4000)
declare @sqlstr2 v ......