Create view statement for Oracle employee Points Ranking

Source: Internet
Author: User

Oracle employee Points Ranking

 

Create View

 

Select t. operate_date,
T. operate_user,
T. operate_dept,
T. add_score +
T. modify_score +
T. over_score +
T. delete_score +
T. up_score +
T. down_score +
T. use_score +
T. opinion_score +
T. advice_score +
T. audit_ OK _score +
T. audit_back_score +
T. read_score

As score
From km_operate_date_log t

 

 

 

Select operate_user, sum (score) from (
Select T. operate_date,
T. operate_user,
T. operate_dept,
T. add_score +
T. modify_score +
T. over_score +
T. delete_score +
T. up_score +
T. down_score +
T. use_score +
T. opinion_score +
T. advice_score +
T. audit_ OK _score +
T. audit_back_score +
T. read_score

As score
From km_operate_date_log t
 
 
) Group by operate_user

 

 

View
Multiple nested select statements affect performance.

Create or replace view km_scoreorder_user
Select operate_user, sum (score) as s_score from (
Select T. operate_date,
T. operate_user,
T. operate_dept,
(T. add_score +
T. modify_score +
T. over_score +
T. delete_score +
T. up_score +
T. down_score +
T. use_score +
T. opinion_score +
T. advice_score +
T. audit_ OK _score +
T. audit_back_score +
T. read_score)

As score
From km_operate_date_log t
)
Group by operate_user;

 

Use a select statement.

Select operate_user, sum (add_score) +
Sum (modify_score) +
Sum (over_score) +
Sum (delete_score) +
Sum (up_score) +
Sum (down_score) +
Sum (use_score) +
Sum (opinion_score) +
Sum (advice_score) +
Sum (audit_ OK _score) +
Sum (audit_back_score) +
Sum (read_score)
As s_score
From km_operate_date_log t
Group by operate_user

 

 

 

Call the created view to retrieve the first few views in SQL.

 

Select row _. *, rownum _ from (
Select * from v_km_operate_sum_score t order by t. sum_score desc
) Row _ where rownum <= 9

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.