Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

SQL Chapter 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1: 2: isql commands can access to the database : Yes ( the answer given is false) 3: SELECT last_name, job_id, salary

AS Sal
FROM employees; This command runs successfully. The column name is changed to Sal from Salary 4: SELECT * FROM job_grades;

Runs successfully 5: SELECT employee_id, last_name sal x 12 ANNUAL SALARY FROM employees;
Errors in above statement are select employee_id, last_name, Salary*12 from employees; SELECT employee_id, last_name, salary *12 "ANNUAL SALARY" FROM employees; Correct syntax 6:to select all the departments in the department table the syntax will be Select * from departments; This shows the output like EPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID 10 20 30 40 Administration 200 Marketing 201 Purchasing 114 Human Resources 1700 1800 1700 203

2400

But when we write the command like Describe departments Select * from departments; Opens in separate window and shows each and every specification like

7: Show the structure of the EMPLOYEES table. Create a query to display the last name, job code, hire date, and employee number for each employee, with employee number appearing first. Provide an alias STARTDATE for the HIRE_DATE column. Save your SQL statement to a file named lab1_7.sql.
select last_name, job_ID, hire_date startdate, employee_ID from employees; LAST_NAME JOB_ID STARTDATE EMPLOYEE_ID 198

OConnell SH_CLERK 6/21/2007 Grant SH_CLERK 1/13/2008 199

To display the employee_id first then select employee_ID,last_name, job_ID, hire_date startdate from employees; 8: if we run the query the result is above 9: Select employee_id from employees; I need to know the difference between the above statement and Select distinct employee_id from employees; Output is same 10: Copy the statement from lab1_7.sql into the iSQL*Plus Edit window. Name the column

headings Emp #, Employee, Job, and Hire Date, respectively. Run your query again. The statement from 7th question is

Select employee_ID,last_name, job_ID, hire_date startdate from employees; Now Select employee_id emp#, last_name employee, job_id job, hire_date hiredate from employees; 11: Display the last name concatenated with the job ID, separated by a comma and space, and name

the column Employee and Title.


Select last_name ||' , '|| Job_Id employee and title from employees; The column name changes to employee and title from last_name ||' , '|| Job_Id 12: Create a query to display all the data from the EMPLOYEES table. Separate each column by a comma. Name the column THE_OUTPUT here we need to use the concatenate operator in between each and every column name like select last_name ||' , '|| job_id ||' , '||hire_date ||' , '||email ||' , '|| phone_number ||' , '|| salary ||' , '|| manager_id ||' , '|| department_id "THEOUTPUT" from employees;

You might also like