SQL Quiz 6

1. In EMP table, print SAL value as the cumulate in the EMPNO ascending sort order as example in the below.

2. In EMP table, print lowest salary among ‘SALESMAN’ employee ranks in order as example in the below.

1
2
3
4
5
6
SELECT job,
ename,
sal,
ROW_NUMBER() OVER(ORDER BY SAL) AS rank
FROM emp
WHERE job = 'SALESMAN'

3. In EMP table, print lowest salary among ‘SALESMAN’ employee ranks in order as example in the below.

1
2
3
4
5
6
SELECT job,
ename,
sal,
RANK() OVER(ORDER BY SAL) AS rank
FROM emp
WHERE job = 'SALESMAN'

4. In EMP table, print lowest salary among ‘SALESMAN’ employee ranks in order as example in the below.

1
2
3
4
5
6
SELECT job,
ename,
sal,
DENSE_RANK() OVER(ORDER BY SAL) AS rank
FROM emp
WHERE job = 'SALESMAN'

5. Print SQL to clone EMP table which for backup. (Table name is ‘EMP_BAK_TABLE)

1
2
CREATE TABLE EMP_BAK_TABLE
AS SELECT * FROM emp;