Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
A:
Q: Query the employee names and their salaries from the employee table.
A: select ename,sal from emp;
Q: Do the above query and use an �as� clause for the �salary� column aliases or
column headings.
A: select ename,sal as salary from emp;
Q: Repeat the previous query and have �Full Name� for the ename�s column heading
and �Salary� for the �sal� column heading.
A: select ename as "Full Name",sal as salary from emp;
Q: Concatenate the customers� last name and first name separated by comma.
A: select lastname||','||firstname from customer;
Q: Query the employees name whose names start with the letter �M.�:
A: select ename from emp where ename like 'M.%';
Q: Query the employees name whose names end with the letter �R.�
A: select ename from emp where ename like '%R.';
Q: Query the employees name whose salaries between 2000 and 3000 dollars.
A: select ename,sal from emp where sal between 2000 and 3000;
Q: Query the department number and their total, average, min, and max salaries
for each department.
A: select deptno,sum(sal),avg(sal),max(sal),min(sal) from emp group by deptno;
Q: Query the department no and their total salaries that have more than 5
employees working in their department.
A: select deptno,sum(sal) from emp group by deptno having count(empno)>5;
Q: Query the employees name that work for the Research or Sales department (the
department number 20 or 30).
A: select ename from emp where deptno in(select deptno from dept where dname
in('RESEARCH','SALES'));
Q: Query the employees name that work in the "accounting" department. Assuming
the department number is unknown.
A: select ename from emp where deptno=(select deptno from dept where dname
='ACCOUNTING');
Q: Query the employees name and use the runtime variable to substitute the
department number? Then run it for following department no 10, 20, and 30.
A:
Such as Employee Id, last name, First name, Phone number and Department number with
the following constraints.
2. Make a check constraint to check the department number is between 9 and 100.
5. Use the "delete cascade" to delete all records if parent gets deleted.
Q: Change the "last_name" column value from �Smith� to �Judd� where the "employee
id" is 100.
A:
Q: Delete all the employee records from the "employee" table using the delete
command and the truncate command.
Q: What is the difference between the delete statement and the truncate
statement?
A:
Q: Copy the �EMP� table to another table and name the new table "employee." In
the new employee table use the employee name, job, commission and department
number.
A: