ora-00934

In PL/SQL, how do you update a row based on the next row?

最后都变了- 提交于 2019-12-12 11:11:06
问题 I'm using Oracle PL/SQL. I have a timestamped table T, and I want to set a row's value for column A to be the same as that of the previous row, if they're sorted by columns B and Timestamp, provided that the timestamps are not different by more than 45 seconds. In pseudocode, it's something like: UPDATE T t_curr SET A = (SELECT A FROM T t_prev INNER JOIN t_curr ON (t_prev is the row right before t_curr, when you sort by B and Timestamp) AND t_curr.Timestamp - t_prev.Timestamp < 45 ) I tried

ORA-00934: Group function not allowed here || Selecting MIN(Salary) of highest paid dept

微笑、不失礼 提交于 2019-12-12 02:29:31
问题 O community, do you know how I could select the department_ID, and lowest salary of the department with the highest average salary? Or how to eliminate the'ORA-00934: group function not allowed here' issue? Would I need to use two subqueries? So far, this is what I've come up with, trying to get the department_ID of the highest paid department: SELECT department_ID, MIN(salary FROM employees WHERE department_ID = (SELECT department_ID FROM employees WHERE salary = MAX(salary)); Thank you,