Over cannot be used alone, with analytic functions: Rank (), Dense_rank (), Row_number (), and so on.
Its parameters: Over (partition by columnname1 ORDER by Columnname2)
Meaning: Group by the field specified by Columname1, or by the value of field columnname1 to sort by group.
For example: In the Employees table, there are two records for the department: department_id = 10 and 20
Select Department_id,rank () over (partition by department_id order by salary) from employees is the ranking of salaries in department 10, Make a salary ranking in department 20. If it is partition by org_id, it is ranked throughout the company.
The following are personal insights:
The over function in SQL and the Row_numbert () function work together to generate line numbers. You can sort the values of a column by grouping the rows of data that have the same value.
Execute statement: Select Row_number () over (order by AID DESC) as rowid,* from BB
Usage of the OVER function in SQL statements