Answers.
Use a select statement to display every SELECT *
field of table TESTDATA.EMPLOYEE. FROM TESTDATA.EMPLOYEE;
Write a query to display each SELECT DEPT
department (DEPT) name in your FROM TESTDATA.EMPLOYEE;
TESTDATA.EMPLOYEE table.
This time display each department SELECT DISTINCT DEPT FROM
name only once. (Duplicate entries TESTDATA.EMPLOYEE;
should not be displayed). Pay attention
to miss spelled department names- if
any)
Display today's date. Make sure it is SELECT SYSDATE FROM
displayed only once. DUAL;
Display each employee's name (first and SELECT F_NAME || ' ' || L_NAME "NAME", (PAYRATE /
last in one field) and pay rate (the 2520) "PAYRATE", (PAYRATE / 365) "DAILY_WAGE",
amount of money s/he makes in a typical (PAYRATE / 12) "MONTHLY_WAGE", PAYRATE
year) from TESTDATA.EMPLOYEE. "YEARLY_WAGE" FROM TESTDATA.EMPLOYEE
Calculate
columns, "Day's Wage" , "Monthly
Wage" and "Hourly Wage". (Assume an
eight hour workday, 30 days month, 365
days/year, and 2520 H/year)
Display the employee last names in one SELECT L_NAME, DEPT || ' ' || ':' || ' ' || B_DATE "DEPT
column and each employee's AND B_DATE"
department concatenated with a space, FROM TESTDATA.EMPLOYEE;
a colon, another space, and their birth
date in second column from
TESTDATA.EMPLOYEE. Give this
column an appropriate heading.
1/10
, Display the last name and address in one SELECT L_NAME || ADDRESS "L_NAME AND ADDRESS",
column, from the TESTDATA.EMPLOYEE (SYSDATE - B_DATE) / 365 "AGE" FROM
table. In TESTDATA.EMPLOYEE;
second field display the Employee's age
(SYSDATE-birth date /365). Give the
columns an appropriate heading. Pay
attention to the way this expression is
evaluated.
Display the name in one field (first and SELECT F_NAME || ' ' || L_NAME "NAME"
last) only for employee with id<200; FROM TESTDATA.EMPLOYEE
from TESTDATA.employee WHERE ID<200;
Display the name in one field (first and SELECT F_NAME || ' ' || L_NAME "Name",
last) and pay rate of each employee PAYRATE
who makes less than 50,000 dollars or FROM TESTDATA.EMPLOYEE
more than 70,000 dollars from WHERE PAYRATE < 50000 OR PAYRATE > 70000;
TESTDATA.employee table. How many
records are there?
Display the name in one field (first and SELECT F_NAME || ' ' || L_NAME "Name",
last) and pay rate of each employee PAYRATE
who makes between 50,000 dollars and FROM TESTDATA.EMPLOYEE
70,000 dollars from WHERE PAYRATE BETWEEN 50000 AND 70000;
TESTDATA.employee table.
List the name (first and last) of SELECT F_NAME || ' ' || L_NAME "NAME"
employees without a phone number FROM TESTDATA.EMPLOYEE
from TESTDATA.employee table. WHERE PHONE IS NULL;
Display each employee's name (first and SELECT F_NAME || ' ' || L_NAME "NAME", ADDRESS,
last), address, and phone number. NVL(PHONE, 999999999) "PHONE" FROM
Provide a null value substitute for phone TESTDATA.EMPLOYEE
number in TESTDATA.employee table. If WHERE PHONE IS NULL;
there is no phone number substitute it
with 9999999999 phone number
Display the name (first and last) and SELECT F_NAME || ' ' || L_NAME "NAME", DEPT FROM
dept of each employee where SSN = TESTDATA.EMPLOYEE
12365214 or SSN = 12245214 or SSN = WHERE SSN IN
891234567or SSN = (12365214,891234567,123456789);
123456789 from TESTDATA.employee
table.
2/10