❶ oracle中统计出某一日按照买入用户数量最多的前五大股票
oracle中的统计分析函数可以按照用户id查询所有股票,然后按照数量由大到小排序。
举例如下:
SELECT
department_id,
first_name||' '||last_name employee_name,
hire_date,
salary,
STDDEV(salary) OVER (PARTITION BY department_id ORDER BY hire_date) AS "STDDEV",
STDDEV_SAMP(salary) OVER (PARTITION BY department_id ORDER BY hire_date) AS "STDDEV_SAMP",
VAR_POP(salary) OVER (PARTITION BY department_id ORDER BY hire_date) AS "VAR_POP",
VAR_SAMP(salary) OVER (PARTITION BY department_id ORDER BY hire_date) AS "VAR_SAMP",
VARIANCE(salary) OVER (PARTITION BY department_id ORDER BY hire_date) AS "VARIANCE"
FROM employees
运行结果: