问题描述
我试图从时间中提取小时数,并添加转换成小时的分钟数,并从时间中提取分钟数,并在Oracle SQL中查找提醒(模)。 到目前为止,我检查了几个链接,然后尝试用Google搜索它,但找不到任何解决方案。 到目前为止,这是我尝试做的事情
const arr = [0,1,2];
const it = arr[Symbol.iterator]();
console.log(it.next(),it.next(),it.next());
这里的问题是我在查询此查询时出错
SELECT
CONCAT(
-- extract hours from time and add minutes converted to hours
(SUM(SUBSTR(m.Time,':',1)) + TRUNCATE((SUM(SUBSTR(m.Time,-1)) / 60),0)),-- extract minutes from time and find reminder (modulo)
LPAD((SUM(SUBSTR(m.Time,-1)) MOD 60),2,0)) hours,CONCAT(CONCAT(u.Surname,' '),u.Lastname) AS Username,u.UserID AS UserId,ut.Date_,m.MomentID
FROM
moments m
LEFT JOIN
user_timesheets ut
ON
ut.UserTimesheetsID = m.UserTimesheetsID
LEFT JOIN
users u
ON
ut.user_id = u.UserID
WHERE
EXTRACT (MONTH FROM TO_DATE(ut.Date_,'YYYY-MM-DD')) = '2020-01-21'
-- EXTRACT (MONTH FROM TO_DATE(ut.Date_)) = '2020-07-30'
AND
EXTRACT (YEAR FROM TO_DATE(ut.Date_,'YYYY-MM-DD')) = '2020-01-21'
-- EXTRACT (YEAR FROM TO_DATE(ut.Date_)) = '2020-07-30'
AND
ut.user_id = 1
AND
(SELECT MAX(MomentID) FROM moments WHERE m.parent = m.MomentID) IS NULL
AND
m.AtestStatus = 1
很抱歉,这个问题对您来说很愚蠢,但我完全是PL / SQL的初学者,我只是在寻求帮助。 干杯:)
更新
由于我现在将%更改为The identifier name started with an ASCII character other than a
letter or a number. After the first character of the identifier
name,ASCII characters are allowed including "$","#" and "_".
Identifiers enclosed in double quotation marks may contain any
character other than a double quotation. Alternate quotation
marks (q'#...#') cannot use spaces,tabs,or carriage returns as
delimiters. For all other contexts,consult the SQL Language
Reference Manual.
*Action: Check the Oracle identifier naming convention. If you are
attempting to provide a password in the IDENTIFIED BY clause of
a CREATE USER or ALTER USER statement,then it is recommended to
always enclose the password in double quotation marks because
characters other than the double quotation are then allowed.
,因此出现错误
MOD
解决方法
这是错误的:
LPAD((SUM(SUBSTR(m.Time,':',-1)) % 60),2,0)
-
this!
标题表示您需要使用 modulo ;如果是这样,Oracle函数名称为MOD
。参见documentation。