下面提到的查询在Oracle SQL中没有编译,查询有什么问题
SELECT AttendanceId, E.FIRSTNAME || ' ' || E.LASTNAME AS FullName, E.EmpID, E.JobCode, E.Address as Location, E.VSMS_Id, A.LoginId,upper(ShiftName) ShiftName,To_char(AttendanceDate, 'dd-MMM-yy') AttendanceDate, to_char(AttendanceDate, 'ddd') as dayName1,
TO_CHAR(ShiftStartTime,'hh:mm tt') ShiftStartTime, TO_CHAR(ShiftEndTime,'hh:mm tt') ShiftEndTime,
TO_CHAR((SignOut,SignIn)/60 )|| ' Hrs' || ':'|| SUBSTR('0' + TO_CHAR( (SignOut,SignIn)%60)(2)),
GREATEST(-LENGTH('0' + TO_CHAR(DATEDIFF(SignOutMinute -SignIn, SignOut)%60 AS VARCHAR2(2))), -2))||' Min' as Duration, SignIn, SignOut, Remark FROM T_ATTENDANCE_ATTENDANCE A
LEFT JOIN USERMASTER U ON U.LOGINID = A.LOGINID
LEFT JOIN EMPLOYEEMASTER E ON E.EMPID = U.EMPID
WHERE EXTRACT(YEAR FROM ATTENDANCEDATE) = V_YEAR AND EXTRACT(MONTH FROM ATTENDANCEDATE) = V_MONTH AND A.active = 1
And a.LoginId = case when nvl(V_LoginId,'') = '' then a.LoginId else V_LoginId end
order by A.AttendanceDate ASC
--------------------------------------------------------------------------------------------------------------------------------------
SELECT E.FIRSTNAME || ' ' || E.LASTNAME AS FullName, E.EmpID, E.JobCode, E.Address as Location,
E.VSMS_Id, A.LoginId,upper(ShiftName) ShiftName, To_char(AttendanceDate, 'dd-MMM-yy') AttendanceDate,
to_char(AttendanceDate, 'ddd') as dayName1, SignIn, SignOut,
TO_CHAR( (SignOut -SignIn) * 1440/60 (5))|| ' Hrs' || ':'|| SUBSTR('0' + TO_CHAR( (SignOut -SignIn) * 1440%60 (2)), GREATEST(-LENGTH('0' + TO_CHAR( DATEDIFF(SignOutMinute -SignIn, SignOut) * 1440%60 AS VARCHAR2(2))), -2))||' Min' as Duration,
case When upper(ShiftName) = 'MORNING' then 1
When upper(ShiftName) = 'GENERAL1' then 2
When upper(ShiftName) = 'GENERAL2' then 3
when upper(ShiftName) = 'AFTERNOON1' then 4
when upper(ShiftName) = 'AFTERNOON2' then 5
When upper(ShiftName) = 'NIGHT' then 6
else 7 end ShiftOrder
FROM T_ATTENDANCE_ATTENDANCE A
LEFT JOIN T_ATTENDANCE_USER_MASTER U ON U.LOGINID = A.LOGINID
LEFT JOIN T_ATTENDANCE_EMPLOYEE_MASTER E ON E.EMPID = U.EMPID
Join T_ATTENDANCE_USER_ATTENDANCE_TEAM uat on uat.LoginId = U.LoginID and uat.isActive = 'Y' and uat.TowerPK =
case when nvl(V_Tower,'') = '' then '' else V_Tower end
and A.Active = 1
AND ATTENDANCEDATE= V_AttendanceDate
字符串
2条答案
按热度按时间u0sqgete1#
简单地说,这不是Oracle。
我注解了部分代码,这些代码肯定不会工作,
datediff
函数%60
也是错误的;我不知道它在你使用的语言中是什么我尽我所能去解决它,我理解。
字符串
s6fujrry2#
您的日期格式模型错误:
MMM
应该是MON
,hh:mm tt
应该是HH24:MI
或HH12:MI AM
,如果您想要日期名称,则ddd
应该是day
(或fmday
)。您还需要修复持续时间代码,因为
DATEDIFF
应该只是减法,而Oracle有MOD
函数(而不是%
运算符);但是,您可以使用EXTRACT
简化该问题:字符串