Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Need to write the query for following conditions

$
0
0

Need to write a query to display the ENAME, SAL, COMM, HIREDATE, NEW_SAL. The NEW_SAL will be calculated by the following rule:

a.         If the employee has joined more than 30 years (as of the date the report is running), then new salary is going to be 1.2 of the old sal, PLUS comm. divided by 12. If there is no commission, treat it as 0.

b.         If the employee has joined less or equal to 30 years, then new salary is going to be the old salary PLUS $100.

Hint: (divide the number of days being hired by 10 years and use TRUNC() function, then decode())

Display the SAL/NEW_SAL with a $ sign in front and using comma ‘,’ to separate thousands

Display the HIREDATE with the format like the following:

Sort the result by the HIREDATE ascending order, then by the new salary descending order.

 

ENAME      SAL               COMM Hiredate       NEW_SAL

---------- ----------- ---------- -------------- -----------

SMITH          $800.00            Dec 17th, 1980     $960.00

ALLEN        $1,600.00        300 Feb 20th, 1981   $1,945.00

Can anyone help me in this?


Viewing all articles
Browse latest Browse all 23857

Trending Articles