Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Using the employees database, select all columns from employees who were hired in October of any year. Limit the results to 50 rows. ===>>> select * from employees where month(hire_date) = 10 limit 50;
- 2. Using the employees database, select all columns from employees database. Show only those employees who were hired in even-numbered days. Limit results to 100.
- ===>>> Select * from employees where day(hire_date) %2 = 0 limit 100;
- 3. (5 points) Display the last name and first name columns as one column labeled "Full Name" with the format "Last Name, First Name" and display the birth_date column labeled "Birth Date". Limit results to 50 rows.
- Output:
- Full Name Birth Date
- Facello, Georgi 1953-09-02
- Simmel, Bezalel 1964-06-02
- ===>>> select comcat(last_name, ", ", first_name) as "Full Name", birth_date as "Birth Date" from employees limit 50
- 4. (10 points) Display all columns from the dept_emp table and display rows for the Marketing department. Limit to 50 rows.
- Output:
- emp_no dept_no from_date to_date
- 11833 (intentionally left blank) 1999-07-15 9999-01-01
- 11841 (intentionally left blank) 1996-04-02 1996-10-24
- ===>>> select * from dept_emp where dept_no = 'd001' limit 50
- 5. (10 points) Show all the salaries for employees during the years 1990, 1993, and 1996. Limit to 100 rows.
- Output:
- emp_no salary from_date to_date
- 10011 56753 '1996-01-21' '1996-11-09'
- 10033 60433 '1993-03-16' '1993-03-24'
- 10082 48935 '1990-01-03' '1990-01-15'
- ===>>> select * from salaries where year(from_date) in(1990, 1993, 1996) and year(to_date) in (1990, 1993, 1996) limit 100
- 6. (5 points) Count the number of male employees who were born in the year 1956. Label the column as "1956 Babies"
- Output:
- 1956 Babies
- 13822
- ===>>> select count(emp_no) as "1956 Babies" from employees where gender = 'm' and year(birth_date) = 1956
- 7. (10 points) For all employees with salaries less than 41,000. Display employee number labeled as "ID #", salary as "Salary" and add a column labeled "Bonus" where the value is 10% of the employee's salary. Limit to 100 rows.
- Output:
- ID # Salary Bonus
- 10003 40006 4000.6
- 10004 40054 4005.4
- 10006 40000 4000.0
- ===>>> select empno as "ID #", salary as "Salary", (salary * .1) as "Bonus" from salaries where salary < 41000 limit 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement