我想做一个oracle查询但是我真的不熟悉,SQL错误信息[Err] ORA-00933: SQL command not properly ended
I would like to make a oracle query but I'm really not familiar with it, SQL error message[Err] ORA-00933: SQL command not properly ended
我有一个 table customerordercapture 和一个列 updatedate。我想 select 在前一天(直到午夜)由客户在 customerordercapture table 中监控的实体,这是最后更新全天数据
我还想要一个查询,我需要在倒数第二个更新日期之前的数据。
查询是从脚本中触发的,因此硬编码日期将不起作用。
我认为我的查询是错误的。
SELECT distinct UPDATEDATE
FROM customerordercapture
GROUP BY UPDATEDATE
HAVING MAX(UPDATEDATE) < = SYSDATE-2
and UPDATEDATE >= MIN(UPDATEDATE)
ORDER BY UPDATEDATE asc ;
SELECT distinct UPDATEDATE
FROM customerordercapture
GROUP BY UPDATEDATE
HAVING UPDATEDATE <= TRUNC(MAX(UPDATEDATE)) - INTERVAL '3' DAY
and UPDATEDATE =TRUNC( MAX(UPDATEDATE) )
ORDER BY UPDATEDATE asc ;
如果我没看错的话,也许对你有帮助:
SELECT MAX(UPDATEDATE), some_column
FROM customerordercapture
WHERE UPDATEDATE <= sysdate
GROUP BY some_column
ORDER BY MAX(UPDATEDATE) asc;
我有一个 table customerordercapture 和一个列 updatedate。我想 select 在前一天(直到午夜)由客户在 customerordercapture table 中监控的实体,这是最后更新全天数据 我还想要一个查询,我需要在倒数第二个更新日期之前的数据。 查询是从脚本中触发的,因此硬编码日期将不起作用。
我认为我的查询是错误的。
SELECT distinct UPDATEDATE
FROM customerordercapture
GROUP BY UPDATEDATE
HAVING MAX(UPDATEDATE) < = SYSDATE-2
and UPDATEDATE >= MIN(UPDATEDATE)
ORDER BY UPDATEDATE asc ;
SELECT distinct UPDATEDATE
FROM customerordercapture
GROUP BY UPDATEDATE
HAVING UPDATEDATE <= TRUNC(MAX(UPDATEDATE)) - INTERVAL '3' DAY
and UPDATEDATE =TRUNC( MAX(UPDATEDATE) )
ORDER BY UPDATEDATE asc ;
如果我没看错的话,也许对你有帮助:
SELECT MAX(UPDATEDATE), some_column
FROM customerordercapture
WHERE UPDATEDATE <= sysdate
GROUP BY some_column
ORDER BY MAX(UPDATEDATE) asc;