简体   繁体   中英

SQL EMP & DEPT - annual salary, commision

List name, annual salary and commision of all Sales whose monthly salary is greater than their commision. the output should be ordered by salary, highest first, if two or more employees have the same salary sort by employee name, within the Lowest salary order.

在此处输入图片说明

Based on the query mentioned in the comments i think you need ROW NUMBER OVER PARTITION. An example would be along the lines

  Select ename, sal*12 as annualsal, com
  ROW_NUMBER() OVER (PARTITION BY sal ORDER BY ename) as RowOrder FROM EMP_TABLE
  WHERE sal < COM
  Order by sal Desc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM