Вы находитесь на странице: 1из 3

QUERIES

FIND THE ERRORS IF ANY.

1. SELECT ,ENAME,JOB,SAL salary FROM EMP;


2. SELECT * FROM SALGRADE
3. SELECT EMPNO,ENAME, SAL*12 Annual Salary FROM EMP;
4. SELECT EMPNO,ENAME,DISTINCT SAL, JOB FROM EMP;
5. SELECT EMPNO,ENAME,SAL,JOB*12 FROM EMP;

CREATE QUERIES TO SOLVE THESE QUESTIONS.

1. SHOW THE STRUCTURE OF DEPT TABLE. SELECT ALL DATA FROM THE DEPT TABLE.
2. SHOW THE STRUCTURE OF EMP TABLE. CREATE A QUERY TO DISPLAY THE (ENAME, JOB,
HIREDATE, AND EMPLOYEE NUMBER FOR EACH EMPLOYEE, WITH EMPLOYEE NUMBER APPEARING
FIRST. SAVE YOUR STATEMENT WITH YOUR FIRST NAME.
3. RUN YOUR QUERY WHICH YOU SAVED WITH YOUR FIRST NAME.
4. CREATE A QUERY TO DISPLAY UNIQUE JOBS FROM THE EMP TABLE.
5. DISPLAY THE NAME CONCATENATED WITH THE JOB, SEPARATED BY A COMMA AND SPACE,
AND NAME THE COLUMN AS EMPLOYEES AND TITLE.
6. CREATE A QUERY TO DISPLAY ALL THE DATA FROM EMP TABLE. SEPARATE EACH COLUMN
BY A COMMA. NAME THE COLUMN THE_OUTPUT.
7. OPEN THE FILE WHICH YOU SAVED WITH YOUR FIRST NAME INTO THE SQL BUFFER. NAME
THE COLUMN HEADING EMP #, EMPLOYEE, JOB, AND HIREDATE, RESPECTIVELY. RERUN YOUR
QUERY.
8. DISPLAY ALL RECORDS IN FOLLOWING FORMAT (FOR ALL RECORD) ON

EMPLOYEE<NAME>WORKS IN DEPARTMENT <NUMBER> AND APPOINTED ON <DATE>

ASSIGNMENT #1
BASIC QUERIES

USE THE FOLLOWING TABLES:

EMP (EMPNO, ENAME, JOB, SAL, HIREDATE, COMM, MGR, DEPTNO)


DEPT (DEPTNO, DNAME, LOC)
SALGRADE (GRADE, LOSAL, HISAL)

PERFORM THE FOLLOWING QUERIES:

1. LIST ALL ROWS OF THE TABLE EMP.

2. LIST ALL ROVVS OF THE DEPT.

3. LIST ALL ROWS OF THE SALGRADE.

4. DISPLAY THE STRUCTURE OF THE TABLE EMP.

5. DISPLAY THE STRUCTURE OF THE TABLE DEPT.

6. DISPLAY THE STRUCTURE OF THE TABLE SALGRADE.

7. LIST ALL TABLES.

8. LIST ALL EMPLOYEES NUMBER FROM EMP.

9. LIST ALL EMPLOYEES NAME FROM EMP.


10. LIST ALL JOBS FROM EMP.

11. LIST ALL SALARIES FROM EMP.

12. LIST ALL HIREDATE FROM EMP.

13. LIST ALL COMMISSION FROM EMP.

14. LIST ALL MGR FROM EMP.

15. LIST ALL DEPARTMENTS NUMBER FROM EMP.

16. LIST ALL EMPLOYEES NUMBER, EMPLOYEES NAME FROM EMP.

17. LIST ALL EMPLOYEES NUMBER, EMPLOYEES NAME, JOBS FROM EMP.

18. LIST ALL EMPLOYEES NUMBER, EMPLOYEES NAME, JOBS, MGR FROM EMP.

19. LIST ALL EMPLOYEES NUMBER, EMPLOYEES NAME, JOBS, MGR, SALARIES FROM EMP.

20. LIST ALL EMPLOYEES NUMBER, EMPLOYEE NAME, JOBS, MGR, SALARIES, HIREDATE FROM
EMP.

21. LIST ALL EMPLOYEES NUMBER, EMPLOYEES NAME, JOBS, MGR, SALARIES, HIREDATE,
COMMISSION FROM EMP.

22. LIST ALL EMPLOYEES NUMBER, EMPLOYEES NAME, JOBS, MGR, SALARIES, HIREDATE,
COMMISSION, DEPARTMENTS NUMBER FROM EMP.

23. LIST ALL EMPLOYEES NUMBER, JOBS FROM EMP.

24. LIST ALL EMPLOYEES NAME, SALARIES FROM EMP.

25. LIST ALL EMPLOYEES NAME, SALARIES COMMISSION FROM EMP.

26. LIST ALL EMPLOYEES NAME, HIREDATE, DEPARTMENTS NUMBER FROM EMP.

27. LIST ALL EMPLOYEES NAME, MGR FROM EMP.

28. LIST ALL JOB, COMMISSION FROM EMP.

29. LIST ALL EMPLOYEES NAME, HIREDATE FROM EMP.

30. LIST ALL EMPLOYEES NAME, DEPARTMENTS NUMBER FROM EMP.

31. LIST ALL JOBS, SALARIES, DEPARTMENTS NUMBER FROM EMP.

32. LIST ALL DEPARTMENTS NUMRER, EMPLOYEES NAME, SALARIES, JOBS FROM EMP.

33. LIST ALL DEPARTMENTS NUMBER FROM DEPARTMENT.

34. LIST ALL DEPARTMENTS NAME FROM DEPARTMENT.

35. LIST ALL LOCATONS FROM DEPARTMENT.

36. LIST ALL DEPARTMENTS NUMBER, DEPARTMENTS NAME FROM DEPARTMENT.

37. LIST ALL DEPARTMENTS NUMBER, LOCATIONS FROM DEPARTMENT.


38. LIST ALL GRADES FROM SALGRADE.

39. LIST ALL LO-SAL FROM SALGRADE.

40. LIST ALL HI-SAL FROM SALGRADE.

41. LIST ALL LO-SAL, HI-SAL, GRADE FROM SALGRADE.

THE END.